Skip to content

Commit

Permalink
Add some zero column tests covering LIMIT, GROUP BY, WHERE, JOIN, and…
Browse files Browse the repository at this point in the history
… 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]>
  • Loading branch information
Kev1n8 and alamb authored Jul 25, 2024
1 parent f12b3db commit 49d9d45
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions datafusion/sqllogictest/test_files/select.slt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 49d9d45

Please sign in to comment.