sarutak commented on a change in pull request #32606:
URL: https://github.com/apache/spark/pull/32606#discussion_r636677458



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/RemoveRedundantProjectsSuite.scala
##########
@@ -215,6 +217,27 @@ abstract class RemoveRedundantProjectsSuiteBase
         |LIMIT 10
         |""".stripMargin
     assertProjectExec(query, 0, 3)
+
+  }
+  Seq("true", "false").foreach { codegenEnabled =>
+    test("SPARK-35287: project generating unsafe row " +
+      s"should not be removed (codegen=$codegenEnabled)") {
+      withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1",

Review comment:
       Please see the comment added.

##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/RemoveRedundantProjectsSuite.scala
##########
@@ -215,6 +217,27 @@ abstract class RemoveRedundantProjectsSuiteBase
         |LIMIT 10
         |""".stripMargin
     assertProjectExec(query, 0, 3)
+
+  }
+  Seq("true", "false").foreach { codegenEnabled =>
+    test("SPARK-35287: project generating unsafe row " +

Review comment:
       Updated.

##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/RemoveRedundantProjectsSuite.scala
##########
@@ -215,6 +217,27 @@ abstract class RemoveRedundantProjectsSuiteBase
         |LIMIT 10
         |""".stripMargin
     assertProjectExec(query, 0, 3)
+
+  }
+  Seq("true", "false").foreach { codegenEnabled =>
+    test("SPARK-35287: project generating unsafe row " +
+      s"should not be removed (codegen=$codegenEnabled)") {
+      withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "-1",
+        SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key -> codegenEnabled,
+        SQLConf.LEAF_NODE_DEFAULT_PARALLELISM.key -> "1") {
+        withTempPath { path =>
+          val format = classOf[SimpleWritableDataSource].getName
+          spark.range(3).select($"id" as "i", $"id" as "j")
+            .write.format(format).mode("overwrite").save(path.getCanonicalPath)
+
+          val df = spark.read.format(format).load(path.getCanonicalPath)
+          val dfLeft = df.as("x")
+          val dfRight = df.as("y")
+          val join = dfLeft.filter(dfLeft("i") > 0).join(dfRight, "i")
+          assert(join.collect === Array(Row(1, 1, 1), Row(2, 2, 2)))

Review comment:
       > Instead of having two tests, how about providing a more meaningful 
error message here with the codegenEnabled value. Then it's easy to tell which 
case fails from the failure message.
   
   If we hit this issue, `ClassCastException` is thrown and error message is 
shown. So the stack trace and error message themselves are meaningful. In that 
case, I think it's better to have `codegenEnabled` value in the test name.
   
   > Also, let's assert the number of project nods in the plan using 
assertProjectExecCount.
   
   The number of `ProjectExec` doesn't matter in this issue. Whether 
`ProjectExec` is placed matters and if it's not placed, `ClassCastException` is 
thrown.




-- 
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.

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