-
Notifications
You must be signed in to change notification settings - Fork 28.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-50130][SQL][FOLLOWUP] Make Encoder generation lazy #48829
base: master
Are you sure you want to change the base?
Conversation
shall we add a test for it? |
@@ -95,13 +95,12 @@ private[sql] object Dataset { | |||
def ofRows(sparkSession: SparkSession, logicalPlan: LogicalPlan): DataFrame = | |||
sparkSession.withActive { | |||
val qe = sparkSession.sessionState.executePlan(logicalPlan) | |||
val encoder = if (qe.isLazyAnalysis) { | |||
RowEncoder.encoderFor(new StructType()) | |||
if (qe.isLazyAnalysis) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we clean up the code a bit more?
if (!qe.isLazyAnalysis) qe.assertAnalyzed()
new Dataset[Row](qe, () => RowEncoder.encoderFor(qe.analyzed.schema))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now with this PR, the encoder creation is lazy only when qe.isLazyAnalysis
, to be consistent with the current behavior. Also the previously failed test suggested to make it consistent.
What changes were proposed in this pull request?
Makes Encoder generation lazy.
Why are the changes needed?
The encoder with empty schema for lazy plan could cause unexpected behavior.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Existing tests.
Was this patch authored or co-authored using generative AI tooling?
No.