PySpark 中的新功能:TVF、子查询、绘图和分析器.pdf

编号:718716 PDF 57页 898.90KB 下载积分:VIP专享
下载报告请您先登录!

PySpark 中的新功能:TVF、子查询、绘图和分析器.pdf

1、Whats New in PySparkTVFs,Subqueries,Plots,and ProfilersTakuya Ueshin,Xinrong MengJune 11,2025IntroductionsTakuya UeshinSr.Software Engineer DatabricksXinrong MengSr.Software Engineer DatabricksAgendaTable-Valued Function APIPython UDTFSubquery Support in the DataFrame APILateral JoinTABLE argumentsP

2、lotting in PySpark WorkflowsProfiling PySpark CodeOther New and Upcoming Features3Your subtitle hereTable-Valued FunctionsTable-Valued Functions in PySparkFunctions that return a table,not a single valueAlready available in SQLBuilt-in TVFs:range,explode,inline,etc.Custom:written via Python UDTFsExa

3、mple TVFfrom pyspark.sql.functions import parse_json,litdf=spark.tvf.variant_explode(parse_json(lit(a:1,b:two)df.show()+-+-+-+|pos|key|value|+-+-+-+|0|a|1|1|b|two|+-+-+-+variant_explodeBuilt-in Table-Valued FunctionsCommonly used built-in TVFs:rangeexplode,explode_outerposexplode,posexplode_outerinl

4、ine,inline_outerstack,json_tuplevariant_explode,variant_explode_outercollations,sql_keywordsAll available under spark.tvf.xxxCan be used as top-level tables or in joinsWhat is a Python UDTF?UDTF=User-Defined Table FunctionReturns multiple rows per input rowschema defined by return typeImplemented by

5、 defining a Python class with:eval()method that yields rowsOptionally polymorphic via analyze()Decorated with udtfExample:RangeWithSquare UDTF from pyspark.sql.functions import udtfudtf(returnType=num INT,squared INT)class RangeWithSquare:def eval(self,start:int,end:int):for i in range(start,end):yi

6、eld(i,i*i)spark.udtf.register(range_with_square,RangeWithSquare)Generating a RangeUsing the UDTF in PySparkfrom pyspark.sql.functions import lit#df=spark.sql(SELECT*FROM range_with_square(1,4)df=RangeWithSquare(lit(1),lit(4)df.show()+-+-+|num|squared|+-+-+|1|1|2|4|3|9|+-+-+Polymorphic UDTFs:Dynamic

友情提示

1、下载报告失败解决办法
2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
4、本站报告下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。

本文(PySpark 中的新功能:TVF、子查询、绘图和分析器.pdf)为本站 (Flechazo) 主动上传,三个皮匠报告文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三个皮匠报告文库(点击联系客服),我们立即给予删除!

温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。
客服
商务合作
小程序
服务号
折叠