Skip to content

Commit 09f1a85

Browse files
committed
move test to SQLQueryTestSuite
1 parent 6e05f14 commit 09f1a85

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

sql/core/src/test/resources/sql-tests/inputs/group-by.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,8 @@ SELECT count(*) FROM test_agg WHERE k = 1 or k = 2 or count(*) + 1L > 1L or max(
179179

180180
-- Aggregate with multiple distinct decimal columns
181181
SELECT AVG(DISTINCT decimal_col), SUM(DISTINCT decimal_col) FROM VALUES (CAST(1 AS DECIMAL(9, 0))) t(decimal_col);
182+
183+
-- SPARK-34581: Don't optimize out grouping expressions from aggregate expressions without aggregate function
184+
SELECT not(a IS NULL), count(*) AS c
185+
FROM testData
186+
GROUP BY a IS NULL

sql/core/src/test/resources/sql-tests/results/group-by.sql.out

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Automatically generated by SQLQueryTestSuite
2-
-- Number of queries: 62
2+
-- Number of queries: 63
33

44

55
-- !query
@@ -642,3 +642,14 @@ SELECT AVG(DISTINCT decimal_col), SUM(DISTINCT decimal_col) FROM VALUES (CAST(1
642642
struct<avg(DISTINCT decimal_col):decimal(13,4),sum(DISTINCT decimal_col):decimal(19,0)>
643643
-- !query output
644644
1.0000 1
645+
646+
647+
-- !query
648+
SELECT not(a IS NULL), count(*) AS c
649+
FROM testData
650+
GROUP BY a IS NULL
651+
-- !query schema
652+
struct<(NOT (a IS NULL)):boolean,c:bigint>
653+
-- !query output
654+
false 2
655+
true 7

sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4140,20 +4140,6 @@ class SQLQuerySuite extends QueryTest with SharedSparkSession with AdaptiveSpark
41404140
}
41414141
}
41424142
}
4143-
4144-
test("SPARK-34581: Don't optimize out grouping expressions from aggregate expressions") {
4145-
withTempView("t") {
4146-
Seq[Integer](null, 1, 2, 3, null).toDF("id").createOrReplaceTempView("t")
4147-
4148-
val df = spark.sql(
4149-
"""
4150-
|SELECT not(t.id IS NULL), count(*) AS c
4151-
|FROM t
4152-
|GROUP BY t.id IS NULL
4153-
|""".stripMargin)
4154-
checkAnswer(df, Row(true, 3) :: Row(false, 2) :: Nil)
4155-
}
4156-
}
41574143
}
41584144

41594145
case class Foo(bar: Option[String])

0 commit comments

Comments
 (0)