viirya commented on code in PR #45350: URL: https://github.com/apache/spark/pull/45350#discussion_r1514903490
########## sql/core/src/test/scala/org/apache/spark/sql/GeneratorFunctionSuite.scala: ########## @@ -553,6 +552,32 @@ class GeneratorFunctionSuite extends QueryTest with SharedSparkSession { checkAnswer(df, Row(0.7604953758285915d)) } } + + test("SPARK-47241: two generator functions in SELECT") { + def testTwoGenerators(needImplicitCast: Boolean): Unit = { + val df = sql( + s""" + |SELECT + |explode(array('a', 'b')) as c1, + |explode(array(0L, ${if (needImplicitCast) "0L + 1" else "1L"})) as c2 + |""".stripMargin) + checkAnswer(df, Seq(Row("a", 0L), Row("a", 1L), Row("b", 0L), Row("b", 1L))) + } + testTwoGenerators(needImplicitCast = true) + testTwoGenerators(needImplicitCast = false) + } + + test("SPARK-47241: generator function after SELECT *") { + val df = sql( + s""" + |SELECT *, explode(array('a', 'b')) as c1 + |FROM + |( + | SELECT id FROM range(1) GROUP BY 1 + |) + |""".stripMargin) + checkAnswer(df, Seq(Row(0, "a"), Row(0, "b"))) + } Review Comment: When I read the PR description, I began wondering what it is "after" `SELECT *`, because I think the `Generate` will be under `Project`: ``` == Physical Plan == *(1) Project [id#1L, c1#2, c1#2] +- *(1) Generate explode([a,b]), [id#1L], false, [c1#2] +- *(1) Range (0, 1, step=1, splits=16) ``` It maybe "before"? -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org