This is an automated email from the ASF dual-hosted git repository.
wenchen pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.3 by this push:
new b4f996a [SPARK-37960][SQL][FOLLOWUP] Make the testing CASE WHEN query
more reasonable
b4f996a is described below
commit b4f996aa49adafda81a14ec272a896019206221e
Author: Jiaan Geng <[email protected]>
AuthorDate: Fri Apr 1 13:34:41 2022 +0800
[SPARK-37960][SQL][FOLLOWUP] Make the testing CASE WHEN query more
reasonable
### What changes were proposed in this pull request?
Some testing CASE WHEN queries are not carefully written and do not make
sense. In the future, the optimizer may get smarter and get rid of the CASE
WHEN completely, and then we loose test coverage.
This PR updates some CASE WHEN queries to make them more reasonable.
### Why are the changes needed?
future-proof test coverage.
### Does this PR introduce _any_ user-facing change?
'No'.
### How was this patch tested?
N/A
Closes #36032 from beliefer/SPARK-37960_followup2.
Authored-by: Jiaan Geng <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
(cherry picked from commit eb353aa959ca2298b28ff0b9671edcfa3ac62822)
Signed-off-by: Wenchen Fan <[email protected]>
---
.../test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git
a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala
index 67a0290..6a0a55b 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala
@@ -888,13 +888,12 @@ class JDBCV2Suite extends QueryTest with
SharedSparkSession with ExplainSuiteHel
| COUNT(CASE WHEN SALARY > 11000 OR SALARY < 10000 THEN SALARY ELSE 0
END),
| COUNT(CASE WHEN SALARY >= 12000 OR SALARY < 9000 THEN SALARY ELSE 0
END),
| COUNT(CASE WHEN SALARY >= 12000 OR NOT(SALARY >= 9000) THEN SALARY
ELSE 0 END),
- | MAX(CASE WHEN NOT(SALARY > 8000) AND SALARY >= 8000 THEN SALARY
ELSE 0 END),
- | MAX(CASE WHEN NOT(SALARY > 8000) OR SALARY > 8000 THEN SALARY ELSE
0 END),
- | MAX(CASE WHEN NOT(SALARY > 8000) AND NOT(SALARY < 8000) THEN SALARY
ELSE 0 END),
+ | MAX(CASE WHEN NOT(SALARY > 10000) AND SALARY >= 8000 THEN SALARY
ELSE 0 END),
+ | MAX(CASE WHEN NOT(SALARY > 10000) OR SALARY > 8000 THEN SALARY ELSE
0 END),
+ | MAX(CASE WHEN NOT(SALARY > 10000) AND NOT(SALARY < 8000) THEN
SALARY ELSE 0 END),
| MAX(CASE WHEN NOT(SALARY != 0) OR NOT(SALARY < 8000) THEN SALARY
ELSE 0 END),
| MAX(CASE WHEN NOT(SALARY > 8000 AND SALARY > 8000) THEN 0 ELSE
SALARY END),
| MIN(CASE WHEN NOT(SALARY > 8000 OR SALARY IS NULL) THEN SALARY ELSE
0 END),
- | SUM(CASE WHEN NOT(SALARY > 8000 AND SALARY IS NOT NULL) THEN SALARY
ELSE 0 END),
| SUM(CASE WHEN SALARY > 10000 THEN 2 WHEN SALARY > 8000 THEN 1 END),
| AVG(CASE WHEN NOT(SALARY > 8000 OR SALARY IS NOT NULL) THEN SALARY
ELSE 0 END)
|FROM h2.test.employee GROUP BY DEPT
@@ -905,9 +904,9 @@ class JDBCV2Suite extends QueryTest with SharedSparkSession
with ExplainSuiteHel
" THEN SALARY ELSE 0.00 END), COUNT(CAS..., " +
"PushedFilters: [], " +
"PushedGroupByColumns: [DEPT], ")
- checkAnswer(df, Seq(Row(1, 1, 1, 1, 1, 0d, 12000d, 0d, 12000d, 12000d, 0d,
0d, 2, 0d),
- Row(2, 2, 2, 2, 2, 0d, 10000d, 0d, 10000d, 10000d, 0d, 0d, 2, 0d),
- Row(2, 2, 2, 2, 2, 0d, 12000d, 0d, 12000d, 12000d, 0d, 0d, 3, 0d)))
+ checkAnswer(df, Seq(Row(1, 1, 1, 1, 1, 0d, 12000d, 0d, 12000d, 12000d, 0d,
2, 0d),
+ Row(2, 2, 2, 2, 2, 10000d, 10000d, 10000d, 10000d, 10000d, 0d, 2, 0d),
+ Row(2, 2, 2, 2, 2, 10000d, 12000d, 10000d, 12000d, 12000d, 0d, 3, 0d)))
}
test("scan with aggregate push-down: aggregate function with binary
arithmetic") {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]