Skip to content

Commit

Permalink
change to SQLQueryTestSuite
Browse files Browse the repository at this point in the history
  • Loading branch information
linhongliu-db committed Sep 10, 2020
1 parent 737f996 commit f2111df
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
3 changes: 3 additions & 0 deletions sql/core/src/test/resources/sql-tests/inputs/group-by.sql
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,6 @@ SELECT * FROM (SELECT COUNT(*) AS cnt FROM test_agg) WHERE cnt > 1L;
SELECT count(*) FROM test_agg WHERE count(*) > 1L;
SELECT count(*) FROM test_agg WHERE count(*) + 1L > 1L;
SELECT count(*) FROM test_agg WHERE k = 1 or k = 2 or count(*) + 1L > 1L or max(k) > 1;

-- Aggregate with multiple distinct decimal columns
SELECT AVG(DISTINCT decimal_col), SUM(DISTINCT decimal_col) FROM VALUES (CAST(1 AS DECIMAL(9, 0))) t(decimal_col);
10 changes: 9 additions & 1 deletion sql/core/src/test/resources/sql-tests/results/group-by.sql.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 56
-- Number of queries: 57


-- !query
Expand Down Expand Up @@ -573,3 +573,11 @@ org.apache.spark.sql.AnalysisException
Aggregate/Window/Generate expressions are not valid in where clause of the query.
Expression in where clause: [(((test_agg.`k` = 1) OR (test_agg.`k` = 2)) OR (((count(1) + 1L) > 1L) OR (max(test_agg.`k`) > 1)))]
Invalid expressions: [count(1), max(test_agg.`k`)];


-- !query
SELECT AVG(DISTINCT decimal_col), SUM(DISTINCT decimal_col) FROM VALUES (CAST(1 AS DECIMAL(9, 0))) t(decimal_col)
-- !query schema
struct<avg(DISTINCT decimal_col):decimal(13,4),sum(DISTINCT decimal_col):decimal(19,0)>
-- !query output
1.0000 1
Original file line number Diff line number Diff line change
Expand Up @@ -2557,14 +2557,13 @@ class DataFrameSuite extends QueryTest
}

test("SPARK-32816: aggregating multiple distinct DECIMAL columns") {
withTempView("test_table") {
spark.range(0, 100, 1, 1)
.selectExpr("id", "cast(id as decimal(9, 0)) as decimal_col")
.createOrReplaceTempView("test_table")
checkAnswer(
sql("select avg(distinct decimal_col), sum(distinct decimal_col) from test_table"),
Row(49.5, 4950))
}
checkAnswer(
sql(
s"""
|SELECT AVG(DISTINCT decimal_col), SUM(DISTINCT decimal_col)
| FROM VALUES (CAST(1 AS DECIMAL(9, 0))) t(decimal_col)
""".stripMargin),
Row(1, 1))
}
}

Expand Down

0 comments on commit f2111df

Please sign in to comment.