问题
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