maropu commented on a change in pull request #30659:
URL: https://github.com/apache/spark/pull/30659#discussion_r539031500
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/RemoveRedundantProjectsSuite.scala
##########
@@ -166,6 +166,53 @@ abstract class RemoveRedundantProjectsSuiteBase
assertProjectExec(query, 0, 1)
}
}
+
+ test("SPARK-33697: UnionExec should require column ordering") {
+ withTable("t1", "t2") {
+ spark.range(-10, 20)
+ .selectExpr(
+ "id",
+ "date_add(date '1950-01-01', cast(id as int)) as datecol",
+ "cast(id as string) strcol")
+ .write.mode("overwrite").format("parquet").saveAsTable("t1")
+ spark.range(-10, 20)
+ .selectExpr(
+ "cast(id as string) strcol",
+ "id",
+ "date_add(date '1950-01-01', cast(id as int)) as datecol")
+ .write.mode("overwrite").format("parquet").saveAsTable("t2")
+
+ val queryTemplate =
+ """
+ |SELECT DISTINCT datecol, strcol FROM
+ |(
+ |(SELECT datecol, id, strcol from t1)
+ | %s
+ |(SELECT datecol, id, strcol from t2)
+ |)
+ |""".stripMargin
+
+ Seq(("UNION", 2, 2), ("UNION ALL", 1, 2)).foreach { case (setOperation,
enabled, disabled) =>
+ val query = queryTemplate.format(setOperation)
+ assertProjectExec(query, enabled = enabled, disabled = disabled)
+ }
+ }
+ }
+
+ test("expand") {
Review comment:
I think you need to add the prefix here, too.
----------------------------------------------------------------
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]