imback82 commented on a change in pull request #27842: [SPARK-31078][SQL] Respect aliases in output ordering URL: https://github.com/apache/spark/pull/27842#discussion_r389331709
########## File path: sql/core/src/test/scala/org/apache/spark/sql/sources/BucketedReadSuite.scala ########## @@ -604,6 +604,18 @@ abstract class BucketedReadSuite extends QueryTest with SQLTestUtils { } } + test("sort should not be introduced when aliases are used") { + withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "0") { + withTable("t") { + df1.repartition(1).write.format("parquet").bucketBy(8, "i").sortBy("i").saveAsTable("t") Review comment: Do you mean something like the following? ``` val t1 = spark.range(10).selectExpr("id as k1").orderBy("k1") .selectExpr("k1 as k11").orderBy("k11") val t2 = spark.range(10).selectExpr("id as k2").orderBy("k2") t1.join(t2, t1("k11") === t2("k2")).explain(true) ``` Extra `Sort` is optimized away, so it doesn't affect the physical plan (no extra sort). ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org