syl
syl

Reputation: 429

Spark: Extract dataframe from logical plan

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 ?

Upvotes: 3

Views: 1471

Answers (1)

Kevin
Kevin

Reputation: 241

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)

Upvotes: 3

Related Questions