From 49d9d45f36989cd448ed6513af65948b6b0100ec Mon Sep 17 00:00:00 2001 From: kf zheng <100595273+Kev1n8@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:53:05 +0800 Subject: [PATCH] Add some zero column tests covering LIMIT, GROUP BY, WHERE, JOIN, and WINDOW (#11624) * add zero column tests covering LIMIT, GROUP BY, WHERE, JOIN, and WINDOW * change from statement to query to be explicit about no rows * Revert "change from statement to query to be explicit about no rows" This reverts commit fd381fca5e9d80f62062c41c4326e4cbe50b2129. --------- Co-authored-by: Andrew Lamb --- datafusion/sqllogictest/test_files/select.slt | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/datafusion/sqllogictest/test_files/select.slt b/datafusion/sqllogictest/test_files/select.slt index 6884efc07e15..a5f31cb9b466 100644 --- a/datafusion/sqllogictest/test_files/select.slt +++ b/datafusion/sqllogictest/test_files/select.slt @@ -1225,6 +1225,63 @@ statement ok SELECT * EXCEPT(a, b, c, d) FROM table1 +# try zero column with LIMIT, 1 row but empty +statement ok +SELECT * EXCEPT (a, b, c, d) +FROM table1 +LIMIT 1 + +# try zero column with GROUP BY, 2 row but empty +statement ok +SELECT * EXCEPT (a, b, c, d) +FROM table1 +GROUP BY a + +# try zero column with WHERE, 1 row but empty +statement ok +SELECT * EXCEPT (a, b, c, d) +FROM table1 +WHERE a = 1 + +# create table2 the same with table1 +statement ok +CREATE TABLE table2 ( + a int, + b int, + c int, + d int +) as values + (1, 10, 100, 1000), + (2, 20, 200, 2000); + +# try zero column with inner JOIN, 2 row but empty +statement ok +WITH t1 AS (SELECT a AS t1_a FROM table1), t2 AS (SELECT a AS t2_a FROM table2) +SELECT * EXCEPT (t1_a, t2_a) +FROM t1 +JOIN t2 ON (t1_a = t2_a) + +# try zero column with more JOIN, 2 row but empty +statement ok +SELECT * EXCEPT (b1, b2) +FROM ( + SELECT b AS b1 FROM table1 +) +JOIN ( + SELECT b AS b2 FROM table2 +) ON b1 = b2 + +# try zero column with Window, 2 row but empty +statement ok +SELECT * EXCEPT (a, b, row_num) +FROM ( + SELECT + a, + b, + ROW_NUMBER() OVER (ORDER BY b) AS row_num + FROM table1 +) + # EXCLUDE order shouldn't matter query II SELECT * EXCLUDE(b, a)