ueshin commented on code in PR #48829:
URL: https://github.com/apache/spark/pull/48829#discussion_r1841253803


##########
sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala:
##########
@@ -95,13 +95,11 @@ 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())
-      } else {
+      if (!qe.isLazyAnalysis) {
         qe.assertAnalyzed()
-        RowEncoder.encoderFor(qe.analyzed.schema)
       }
-      new Dataset[Row](qe, encoder)
+      val encoder = () => RowEncoder.encoderFor(qe.analyzed.schema)
+      new Dataset[Row](qe, encoder())

Review Comment:
   No, the signature of the constructor changed to `lazyEncoder: => 
Encoder[T]`, so it should be invoked later.
   I changed it to make it clearer and to fix the test failures at 584c650.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to