Skip to content

Commit 49d9d45

Browse files
Kev1n8alamb
andauthored
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 fd381fc. --------- Co-authored-by: Andrew Lamb <[email protected]>
1 parent f12b3db commit 49d9d45

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

datafusion/sqllogictest/test_files/select.slt

+57
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,63 @@ statement ok
12251225
SELECT * EXCEPT(a, b, c, d)
12261226
FROM table1
12271227

1228+
# try zero column with LIMIT, 1 row but empty
1229+
statement ok
1230+
SELECT * EXCEPT (a, b, c, d)
1231+
FROM table1
1232+
LIMIT 1
1233+
1234+
# try zero column with GROUP BY, 2 row but empty
1235+
statement ok
1236+
SELECT * EXCEPT (a, b, c, d)
1237+
FROM table1
1238+
GROUP BY a
1239+
1240+
# try zero column with WHERE, 1 row but empty
1241+
statement ok
1242+
SELECT * EXCEPT (a, b, c, d)
1243+
FROM table1
1244+
WHERE a = 1
1245+
1246+
# create table2 the same with table1
1247+
statement ok
1248+
CREATE TABLE table2 (
1249+
a int,
1250+
b int,
1251+
c int,
1252+
d int
1253+
) as values
1254+
(1, 10, 100, 1000),
1255+
(2, 20, 200, 2000);
1256+
1257+
# try zero column with inner JOIN, 2 row but empty
1258+
statement ok
1259+
WITH t1 AS (SELECT a AS t1_a FROM table1), t2 AS (SELECT a AS t2_a FROM table2)
1260+
SELECT * EXCEPT (t1_a, t2_a)
1261+
FROM t1
1262+
JOIN t2 ON (t1_a = t2_a)
1263+
1264+
# try zero column with more JOIN, 2 row but empty
1265+
statement ok
1266+
SELECT * EXCEPT (b1, b2)
1267+
FROM (
1268+
SELECT b AS b1 FROM table1
1269+
)
1270+
JOIN (
1271+
SELECT b AS b2 FROM table2
1272+
) ON b1 = b2
1273+
1274+
# try zero column with Window, 2 row but empty
1275+
statement ok
1276+
SELECT * EXCEPT (a, b, row_num)
1277+
FROM (
1278+
SELECT
1279+
a,
1280+
b,
1281+
ROW_NUMBER() OVER (ORDER BY b) AS row_num
1282+
FROM table1
1283+
)
1284+
12281285
# EXCLUDE order shouldn't matter
12291286
query II
12301287
SELECT * EXCLUDE(b, a)

0 commit comments

Comments
 (0)