Spark: Extract dataframe from logical plan

∥☆過路亽.° 提交于 2021-01-03 06:29:07

问题


This line of code converts a dataFrame to a logical plan

val logical = df.queryExecution.logical

Can we do the opposite, meaning extracting from the logical plan, the dataframes used ?


回答1:


in Dataset object there is a method:

def ofRows(sparkSession: SparkSession, logicalPlan: LogicalPlan)

so if you have a logical plan, you can transform it into a DataFrame by calling Dataset.ofRows(sparkSession, logical)



来源:https://stackoverflow.com/questions/43763246/spark-extract-dataframe-from-logical-plan

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!