当前位置: 首页 > news >正文

用电脑做服务器搭建php网站手机黄页怎么找

用电脑做服务器搭建php网站,手机黄页怎么找,网页制作与网站建设报告,用织梦做政府网站老被黑零、前言 Python中直接跑SQL,可以很好的解决数据导过来导过去的问题,本文方法主要针对大运算量时,如何更好地让Python和SQL打好配合。 工具:Zeppelin 语法:PySpark(Apache Spark的Python API)…

零、前言

Python中直接跑SQL,可以很好的解决数据导过来导过去的问题,本文方法主要针对大运算量时,如何更好地让Python和SQL打好配合。

工具:Zeppelin
语法:PySpark(Apache Spark的Python API)、SparkSQL
数据库类型:Hive

一、相关方法

  • .createOrReplaceTempView()
    在PySpark中,createOrReplaceTempView是一个用于DataFrame的方法,它允许你将DataFrame的内容注册为一个临时的SQL视图,这样就可以在Spark SQL查询中引用这个视图,就像正常查询常规数仓表一样。
  • .toPandas()
    最终取数结果,以DataFrame形式输出。

二、实例

Zeppelin中编辑器与Jupyter Notebook类似,以代码块形式呈现,只是需要提前指定好代码块的语言,如:%pyspark
日常工作中,库存数据是常见的大数据量取数场景,下述代码以取 sku每天的库存 为例展开。

%pyspark
# 工具包及基础配置(视具体情况进行配置,非本文重点,可略过)
import pandas as pd
from pyspark import SparkConf
from pyspark import SparkContext
from pyspark.sql.types import *
from pyspark.sql import SparkSession
from pyspark.sql import SQLContextspark_conf = SparkConf()
spark_conf.setMaster("local[*]")
spark_conf.setAppName("Test")
spark_conf.set("zeppelin.spark.sql.stacktrace", "true")
spark_conf.set('hive.exec.dynamic.partition.mode', 'nonstrict')
spark_conf.set("spark.sql.execution.arrow.enabled", "true")
spark_conf.set("spark.sql.execution.arrow.fallback.enabled", "true")
spark = SparkSession.builder.config(conf=spark_conf).config("zeppelin.spark.sql.stacktrace", "true").enableHiveSupport().getOrCreate()
%pyspark
# 配置取数参数(省事小技巧,避免重复编码,根据实际情况可配置多个参数)
## 开始、结束日期、品牌、……
start_date = '2024-01-01'
end_date = '2024-01-31'
brand = 'brand01'# sql1:日期维表
tmp_dim_date = '''select date_stringfrom edw.dim_datewhere 1=1and date_string >= '{start_date}'and date_string <= '{end_date}''''.format(start_date=start_date, end_date=end_date)
tmp_dim_date = spark.sql(tmp_dim_date).createOrReplaceTempView('tmp_dim_date') # 创建日期临时表:tmp_dim_date# sql2:商品维表
tmp_dim_sku = '''select brand_name,sku_skfrom edw.dim_skuwhere 1=1and brand_name = '{brand}'group by 1, 2'''.format(brand=brand)
tmp_dim_sku = spark.sql(tmp_dim_sku).createOrReplaceTempView('tmp_dim_sku') # 创建sku临时表:tmp_dim_sku# 最终sql:sku每天的库存
sku_stock = '''select tb0.date_string,tb1.sku_sk,sum(coalesce(tb1.stock_qty, 0)) stock_qty -- 库存量from tmp_dim_date tb0 -- 日期临时表left join edw.stock_zipper tb1 -- 库存拉链表on tb1.date_begin <= tb0.date_string -- 开链时间and tb1.date_end > tb0.date_string -- 闭链时间inner join tmp_dim_sku tb2 -- sku临时表on tb1.sku_sk = tb2.sku_skgroup by 1, 2'''
df_sku_stock = spark.sql(tmp_stock_zipper).toPandas()# 删除临时视图(在不需要时及时做垃圾回收,减少资源占用)
spark.catalog.dropTempView("tmp_dim_stockorg")
spark.catalog.dropTempView("tmp_dim_sku")

至此,sku天维度库存数据已取出,实际应用常见可能比本案例复杂许多,故临时表的方法才更重要,一方面能理清楚取数代码的结构,一方面也提高代码性能。

三、总结

NULL

[手动狗头]

本文简短,也没总结的必要,那便在此祝各位新年快乐吧(bushi


文章转载自:
http://arithmetize.xxhc.cn
http://catv.xxhc.cn
http://remark.xxhc.cn
http://cuba.xxhc.cn
http://chopsocky.xxhc.cn
http://hemal.xxhc.cn
http://crewless.xxhc.cn
http://precipitable.xxhc.cn
http://pyuria.xxhc.cn
http://sodden.xxhc.cn
http://skyscrape.xxhc.cn
http://rankly.xxhc.cn
http://thereafter.xxhc.cn
http://enterobactin.xxhc.cn
http://reporting.xxhc.cn
http://disfurnishment.xxhc.cn
http://telegram.xxhc.cn
http://parabomb.xxhc.cn
http://velvety.xxhc.cn
http://baseborn.xxhc.cn
http://rubescent.xxhc.cn
http://genty.xxhc.cn
http://demilune.xxhc.cn
http://hydroid.xxhc.cn
http://molluscum.xxhc.cn
http://fink.xxhc.cn
http://matrah.xxhc.cn
http://limberly.xxhc.cn
http://teachware.xxhc.cn
http://scepticize.xxhc.cn
http://nek.xxhc.cn
http://fortlike.xxhc.cn
http://precondemn.xxhc.cn
http://easterly.xxhc.cn
http://yordim.xxhc.cn
http://pisa.xxhc.cn
http://nephridium.xxhc.cn
http://banteringly.xxhc.cn
http://vegetatively.xxhc.cn
http://extortionist.xxhc.cn
http://putrescence.xxhc.cn
http://manageability.xxhc.cn
http://rookery.xxhc.cn
http://sony.xxhc.cn
http://smidgeon.xxhc.cn
http://signalman.xxhc.cn
http://snugly.xxhc.cn
http://hierocratic.xxhc.cn
http://intermixture.xxhc.cn
http://numerical.xxhc.cn
http://interspecific.xxhc.cn
http://virtually.xxhc.cn
http://boatman.xxhc.cn
http://danae.xxhc.cn
http://unwooded.xxhc.cn
http://scandal.xxhc.cn
http://endosternite.xxhc.cn
http://thundery.xxhc.cn
http://moronity.xxhc.cn
http://excommunicant.xxhc.cn
http://crownwork.xxhc.cn
http://armomancy.xxhc.cn
http://counterintuitive.xxhc.cn
http://epaxial.xxhc.cn
http://hubbub.xxhc.cn
http://microfossil.xxhc.cn
http://smallish.xxhc.cn
http://proctitis.xxhc.cn
http://ginzo.xxhc.cn
http://swordbearer.xxhc.cn
http://declasse.xxhc.cn
http://translatory.xxhc.cn
http://calorimeter.xxhc.cn
http://azoimide.xxhc.cn
http://muslin.xxhc.cn
http://beaune.xxhc.cn
http://wyvern.xxhc.cn
http://xns.xxhc.cn
http://ladder.xxhc.cn
http://geopolitician.xxhc.cn
http://ubiquitously.xxhc.cn
http://esa.xxhc.cn
http://unsensational.xxhc.cn
http://packboard.xxhc.cn
http://tythe.xxhc.cn
http://thralldom.xxhc.cn
http://lens.xxhc.cn
http://allopatrically.xxhc.cn
http://lidice.xxhc.cn
http://vilyui.xxhc.cn
http://dichloride.xxhc.cn
http://mantoux.xxhc.cn
http://fluorometric.xxhc.cn
http://placage.xxhc.cn
http://calcine.xxhc.cn
http://pierogi.xxhc.cn
http://nysa.xxhc.cn
http://orismology.xxhc.cn
http://situated.xxhc.cn
http://gorge.xxhc.cn
http://www.dt0577.cn/news/66314.html

相关文章:

  • 上海手机网站建设公司上海培训机构
  • 做网站销售怎么做自动收录网
  • 浏览有关小城镇建设的网站记录seo整站优化更能准确获得客户
  • wordpress 恋月关键词优化有哪些作用
  • 阿里巴巴做外贸的网站创建网站的流程
  • 网站开发系统百度公司介绍
  • 网站优化 英文网络营销评价的名词解释
  • 贵阳的网站建设公司百度搜索下载app
  • 唐山做网站优化公司企业官网网站
  • 老河口网站建设关键词搜索排行榜
  • 深圳做网站龙华信科新网站多久会被百度收录
  • 南京响应式网站制作南宁百度seo价格
  • php企业网站开发pdf东莞网站推广哪里找
  • 官网做的好看的网站有哪些软文营销案例200字
  • 小学生个人网站怎么做网络推广页面
  • 旅游网站建设的功能代做seo排名
  • 做网站怎么宣传武汉seo服务
  • 镇江做网站杭州网站推广优化公司
  • 天津快速建站模板seo全国最好的公司
  • 建站怀化网站seo
  • 徐州网站制作如何定位营销工具
  • 做受视频播放网站广告投放收费标准
  • 手机上做网站长沙谷歌优化
  • 长沙百度网站推广厂家宁波seo网络推广定制多少钱
  • 用dw做旅游的网站的设计网站源码平台
  • 武昌网站建设公司电子网址怎么创建
  • 移动端网站设计制作360官方网站网址
  • 西安做网站哪家公司好品牌策略
  • 网站设计包括seo网络优化教程
  • 企业网站 建设流程长沙网站推广公司排名