Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/17191#discussion_r106814321 --- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala --- @@ -2598,4 +2598,27 @@ class SQLQuerySuite extends QueryTest with SharedSQLContext { } assert(!jobStarted.get(), "Command should not trigger a Spark job.") } + + test("SPARK-14471 When groupByAliasesEnabled=true, aliases in SELECT could exist in GROUP BY") { + withSQLConf(SQLConf.GROUP_BY_ALIASES_ENABLED.key -> "true", + SQLConf.GROUP_BY_ORDINAL.key -> "true") { + Seq((1, "a", 0), (2, "a", 1), (1, "a", 2)).toDF("k1", "k2", "v") + .createOrReplaceTempView("t") + checkAnswer( + sql("SELECT k1 AS key1, k2 AS key2, SUM(v) FROM t GROUP BY key1, key2"), + Row(1, "a", 2) :: Row(2, "a", 1) :: Nil) + // Check mixed cases: group-by ordinals and aliases + checkAnswer( + sql("SELECT k1, k2 AS key2, SUM(v) FROM t GROUP BY key2, 1"), + Row(1, "a", 2) :: Row(2, "a", 1) :: Nil) + } + withSQLConf(SQLConf.GROUP_BY_ALIASES_ENABLED.key -> "false") { + Seq((1, "a", 0), (2, "a", 1), (1, "a", 2)).toDF("k1", "k2", "v") + .createOrReplaceTempView("t") --- End diff -- Please remove it. Thanks!
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org