Skip to content

Commit

Permalink
test: skip unsupported features and add sources
Browse files Browse the repository at this point in the history
  • Loading branch information
CookiePieWw committed Nov 18, 2024
1 parent 386b2cb commit 24bcea4
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 46 deletions.
81 changes: 51 additions & 30 deletions tests/cases/standalone/common/subquery/table.result
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-- aliasing
-- aliasing, from:
-- https://github.com/duckdb/duckdb/blob/9196dd9b0a163e6c8aada26218803d04be30c562/test/sql/subquery/table/test_aliasing.test
CREATE TABLE a(ts TIMESTAMP TIME INDEX, i INTEGER);

Affected Rows: 0
Expand All @@ -7,15 +8,15 @@ insert into a values (1, 42);

Affected Rows: 1

select * from (select i as j from a group by j) where j = 42;
SELECT * FROM (SELECT i AS j FROM a GROUP BY j) WHERE j = 42;

+----+
| j |
+----+
| 42 |
+----+

select * from (select i as j from a group by i) where j = 42;
SELECT * FROM (SELECT i AS j FROM a GROUP BY i) WHERE j = 42;

+----+
| j |
Expand All @@ -27,7 +28,8 @@ DROP TABLE a;

Affected Rows: 0

-- nested table subquery
-- nested table subquery, from:
-- https://github.com/duckdb/duckdb/blob/2e4e2913266ddc46c7281d1b992228cb0095954b/test/sql/subquery/table/test_nested_table_subquery.test_slow
CREATE TABLE test (ts TIMESTAMP TIME INDEX, i INTEGER, j INTEGER);

Affected Rows: 0
Expand Down Expand Up @@ -59,7 +61,8 @@ DROP TABLE test;

Affected Rows: 0

-- subquery union
-- subquery union, from:
-- https://github.com/duckdb/duckdb/blob/9196dd9b0a163e6c8aada26218803d04be30c562/test/sql/subquery/table/test_subquery_union.test
SELECT * FROM (SELECT 42) UNION ALL SELECT * FROM (SELECT 43);

+-----------+
Expand All @@ -69,7 +72,8 @@ SELECT * FROM (SELECT 42) UNION ALL SELECT * FROM (SELECT 43);
| 43 |
+-----------+

-- table subquery
-- table subquery, from:
-- https://github.com/duckdb/duckdb/blob/8704c7d0807d6ce1e2ebcdf6398e1b6cc050e507/test/sql/subquery/table/test_table_subquery.test
CREATE TABLE test (ts TIMESTAMP TIME INDEX, i INTEGER, j INTEGER);

Affected Rows: 0
Expand Down Expand Up @@ -116,26 +120,43 @@ SELECT * FROM (SELECT i, j FROM test) AS a, (SELECT i+1 AS r,j FROM test) AS b,
| 5 | 6 | 5 | 5 | 1970-01-01T00:00:00.001 | 4 | 5 |
+---+---+---+---+-------------------------+---+---+

DROP TABLE test;
SELECT sum(x) FROM (SELECT i AS x FROM test GROUP BY i) sq;

Affected Rows: 0
+-----------+
| SUM(sq.x) |
+-----------+
| 12 |
+-----------+

-- test unamed subquery
SELECT * FROM (SELECT 42);
SELECT sum(x) FROM (SELECT i+1 AS x FROM test GROUP BY x) sq;

+-----------+
| Int64(42) |
| SUM(sq.x) |
+-----------+
| 42 |
| 15 |
+-----------+

SELECT * FROM (SELECT 42), (SELECT 43);
DROP TABLE test;

Affected Rows: 0

-- test unamed subquery, from:
-- https://github.com/duckdb/duckdb/blob/00a605270719941ca0412ad5d0a14b1bdfbf9eb5/test/sql/subquery/table/test_unnamed_subquery.test
SELECT a FROM (SELECT 42 a);

+----+
| a |
+----+
| 42 |
+----+

SELECT * FROM (SELECT 42 a), (SELECT 43 b);

+-----------+-----------+
| Int64(42) | Int64(43) |
+-----------+-----------+
| 42 | 43 |
+-----------+-----------+
+----+----+
| a | b |
+----+----+
| 42 | 43 |
+----+----+

SELECT * FROM (VALUES (42, 43));

Expand All @@ -145,19 +166,19 @@ SELECT * FROM (VALUES (42, 43));
| 42 | 43 |
+---------+---------+

SELECT * FROM (SELECT 42), (SELECT 43), (SELECT 44), (SELECT 45);
SELECT * FROM (SELECT 42 a), (SELECT 43 b), (SELECT 44 c), (SELECT 45 d);

+-----------+-----------+-----------+-----------+
| Int64(42) | Int64(43) | Int64(44) | Int64(45) |
+-----------+-----------+-----------+-----------+
| 42 | 43 | 44 | 45 |
+-----------+-----------+-----------+-----------+
+----+----+----+----+
| a | b | c | d |
+----+----+----+----+
| 42 | 43 | 44 | 45 |
+----+----+----+----+

SELECT * FROM (SELECT * FROM (SELECT 42), (SELECT 43)) JOIN (SELECT 44) ON (true) JOIN (SELECT 45) ON (true);
SELECT * FROM (SELECT * FROM (SELECT 42 a), (SELECT 43 b)) JOIN (SELECT 44 c) ON (true) JOIN (SELECT 45 d) ON (true);

+-----------+-----------+-----------+-----------+
| Int64(42) | Int64(43) | Int64(44) | Int64(45) |
+-----------+-----------+-----------+-----------+
| 42 | 43 | 44 | 45 |
+-----------+-----------+-----------+-----------+
+----+----+----+----+
| a | b | c | d |
+----+----+----+----+
| 42 | 43 | 44 | 45 |
+----+----+----+----+

36 changes: 25 additions & 11 deletions tests/cases/standalone/common/subquery/table.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
-- aliasing
-- aliasing, from:
-- https://github.com/duckdb/duckdb/blob/9196dd9b0a163e6c8aada26218803d04be30c562/test/sql/subquery/table/test_aliasing.test
CREATE TABLE a(ts TIMESTAMP TIME INDEX, i INTEGER);

insert into a values (1, 42);

select * from (select i as j from a group by j) where j = 42;
SELECT * FROM (SELECT i AS j FROM a GROUP BY j) WHERE j = 42;

select * from (select i as j from a group by i) where j = 42;
SELECT * FROM (SELECT i AS j FROM a GROUP BY i) WHERE j = 42;

DROP TABLE a;

-- nested table subquery
-- nested table subquery, from:
-- https://github.com/duckdb/duckdb/blob/2e4e2913266ddc46c7281d1b992228cb0095954b/test/sql/subquery/table/test_nested_table_subquery.test_slow
CREATE TABLE test (ts TIMESTAMP TIME INDEX, i INTEGER, j INTEGER);

INSERT INTO test VALUES (0, 3, 4), (1, 4, 5), (2, 5, 6);
Expand All @@ -20,10 +22,12 @@ SELECT i FROM (SELECT i + 1 AS i FROM (SELECT i + 1 AS i FROM (SELECT i + 1 AS i

DROP TABLE test;

-- subquery union
-- subquery union, from:
-- https://github.com/duckdb/duckdb/blob/9196dd9b0a163e6c8aada26218803d04be30c562/test/sql/subquery/table/test_subquery_union.test
SELECT * FROM (SELECT 42) UNION ALL SELECT * FROM (SELECT 43);

-- table subquery
-- table subquery, from:
-- https://github.com/duckdb/duckdb/blob/8704c7d0807d6ce1e2ebcdf6398e1b6cc050e507/test/sql/subquery/table/test_table_subquery.test
CREATE TABLE test (ts TIMESTAMP TIME INDEX, i INTEGER, j INTEGER);

INSERT INTO test VALUES (0, 3, 4), (1, 4, 5), (2, 5, 6);
Expand All @@ -36,15 +40,25 @@ SELECT a.i,a.j,b.r,b.j FROM (SELECT i, j FROM test) AS a INNER JOIN (SELECT i+1

SELECT * FROM (SELECT i, j FROM test) AS a, (SELECT i+1 AS r,j FROM test) AS b, test WHERE a.i=b.r AND test.j=a.i ORDER BY 1;

SELECT sum(x) FROM (SELECT i AS x FROM test GROUP BY i) sq;

SELECT sum(x) FROM (SELECT i+1 AS x FROM test GROUP BY x) sq;

DROP TABLE test;

-- test unamed subquery
SELECT * FROM (SELECT 42);
-- test unamed subquery, from:
-- https://github.com/duckdb/duckdb/blob/00a605270719941ca0412ad5d0a14b1bdfbf9eb5/test/sql/subquery/table/test_unnamed_subquery.test
SELECT a FROM (SELECT 42 a);

SELECT * FROM (SELECT 42), (SELECT 43);
SELECT * FROM (SELECT 42 a), (SELECT 43 b);

SELECT * FROM (VALUES (42, 43));

SELECT * FROM (SELECT 42), (SELECT 43), (SELECT 44), (SELECT 45);
SELECT * FROM (SELECT 42 a), (SELECT 43 b), (SELECT 44 c), (SELECT 45 d);

SELECT * FROM (SELECT * FROM (SELECT 42 a), (SELECT 43 b)) JOIN (SELECT 44 c) ON (true) JOIN (SELECT 45 d) ON (true);

SELECT * FROM (SELECT * FROM (SELECT 42), (SELECT 43)) JOIN (SELECT 44) ON (true) JOIN (SELECT 45) ON (true);
-- skipped, unsupported feature: unnamed_subquery, see also:
-- https://github.com/GreptimeTeam/greptimedb/issues/5012
-- SELECT * FROM (SELECT unnamed_subquery.a FROM (SELECT 42 a)), (SELECT unnamed_subquery.b FROM (SELECT 43 b));
-- SELECT unnamed_subquery.a, unnamed_subquery2.b FROM (SELECT 42 a), (SELECT 43 b);
12 changes: 8 additions & 4 deletions tests/cases/standalone/common/subquery/test_neumann.result
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- from:
-- https://github.com/duckdb/duckdb/blob/74687ec572e9e6ccf34f9b15daa62998b34a3e13/test/sql/subquery/test_neumann.test
CREATE TABLE students(ts TIMESTAMP TIME INDEX, id INTEGER, n VARCHAR, major VARCHAR, y INTEGER);

Affected Rows: 0
Expand Down Expand Up @@ -40,10 +42,12 @@ SELECT s.n, e.course, e.grade FROM students s, exams e WHERE s.id=e.sid AND e.gr
| Mark | Database Systems | 10 |
+------+------------------+-------+

SELECT n, major FROM students s WHERE EXISTS(SELECT * FROM exams e WHERE e.sid=s.id AND grade=10) OR s.n='Dirk' ORDER BY n;

Error: 3001(EngineExecuteQuery), DataFusion error: This feature is not implemented: Physical plan does not support logical expression Exists(Exists { subquery: <subquery>, negated: false })

-- skipped, unsupported feature: correlated column in predicate, see also:
-- https://github.com/GreptimeTeam/greptimedb/issues/5012
-- SELECT s.n, e.course, e.grade FROM students s, exams e WHERE s.id=e.sid AND (s.major = 'CS' OR s.major = 'Games Eng') AND e.grade <= (SELECT AVG(e2.grade) - 1 FROM exams e2 WHERE s.id=e2.sid OR (e2.curriculum=s.major AND s.y>=e2.y)) ORDER BY n, course;
-- skipped, unsupported feature: exists, see also:
-- https://github.com/GreptimeTeam/greptimedb/issues/5012
-- SELECT n, major FROM students s WHERE EXISTS(SELECT * FROM exams e WHERE e.sid=s.id AND grade=10) OR s.n='Dirk' ORDER BY n;
DROP TABLE students;

Affected Rows: 0
Expand Down
10 changes: 9 additions & 1 deletion tests/cases/standalone/common/subquery/test_neumann.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- from:
-- https://github.com/duckdb/duckdb/blob/74687ec572e9e6ccf34f9b15daa62998b34a3e13/test/sql/subquery/test_neumann.test
CREATE TABLE students(ts TIMESTAMP TIME INDEX, id INTEGER, n VARCHAR, major VARCHAR, y INTEGER);

CREATE TABLE exams(ts TIMESTAMP TIME INDEX, sid INTEGER, course VARCHAR, curriculum VARCHAR, grade INTEGER, y INTEGER);
Expand All @@ -16,7 +18,13 @@ INSERT INTO exams VALUES (4, 2, 'Graphics', 'CS', 7, 2016);

SELECT s.n, e.course, e.grade FROM students s, exams e WHERE s.id=e.sid AND e.grade=(SELECT MAX(e2.grade) FROM exams e2 WHERE s.id=e2.sid) ORDER BY n, course;

SELECT n, major FROM students s WHERE EXISTS(SELECT * FROM exams e WHERE e.sid=s.id AND grade=10) OR s.n='Dirk' ORDER BY n;
-- skipped, unsupported feature: correlated column in predicate, see also:
-- https://github.com/GreptimeTeam/greptimedb/issues/5012
-- SELECT s.n, e.course, e.grade FROM students s, exams e WHERE s.id=e.sid AND (s.major = 'CS' OR s.major = 'Games Eng') AND e.grade <= (SELECT AVG(e2.grade) - 1 FROM exams e2 WHERE s.id=e2.sid OR (e2.curriculum=s.major AND s.y>=e2.y)) ORDER BY n, course;

-- skipped, unsupported feature: exists, see also:
-- https://github.com/GreptimeTeam/greptimedb/issues/5012
-- SELECT n, major FROM students s WHERE EXISTS(SELECT * FROM exams e WHERE e.sid=s.id AND grade=10) OR s.n='Dirk' ORDER BY n;

DROP TABLE students;

Expand Down

0 comments on commit 24bcea4

Please sign in to comment.