-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: filter_push_down and catalog test
- Loading branch information
1 parent
5406731
commit 7f15bac
Showing
5 changed files
with
341 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
SELECT SUM(number) FROM numbers; | ||
|
||
+--------------------------------------+ | ||
| SUM(numbers.number), #Field, #Uint64 | | ||
+--------------------------------------+ | ||
| 4950 | | ||
+--------------------------------------+ | ||
|
||
SELECT SUM(1) FROM numbers; | ||
|
||
+-------------------------------+ | ||
| SUM(Int64(1)), #Field, #Int64 | | ||
+-------------------------------+ | ||
| 100 | | ||
+-------------------------------+ | ||
|
||
SELECT SUM(-1) FROM numbers; | ||
|
||
+--------------------------------+ | ||
| SUM(Int64(-1)), #Field, #Int64 | | ||
+--------------------------------+ | ||
| -100 | | ||
+--------------------------------+ | ||
|
||
SELECT SUM(-1) FROM numbers WHERE number=-1; | ||
|
||
+--------------------------------+ | ||
| SUM(Int64(-1)), #Field, #Int64 | | ||
+--------------------------------+ | ||
| NULL | | ||
+--------------------------------+ | ||
|
||
SELECT SUM(-1) FROM numbers WHERE number>10000 limit 1000; | ||
|
||
+--------------------------------+ | ||
| SUM(Int64(-1)), #Field, #Int64 | | ||
+--------------------------------+ | ||
| NULL | | ||
+--------------------------------+ | ||
|
||
CREATE TABLE bigints(b BIGINT TIME INDEX); | ||
|
||
MutateResult { success: 1, failure: 0 } | ||
|
||
INSERT INTO bigints values (4611686018427387904), (4611686018427388904), (1); | ||
|
||
MutateResult { success: 3, failure: 0 } | ||
|
||
SELECT SUM(b) FROM bigints; | ||
|
||
+--------------------------------+ | ||
| SUM(bigints.b), #Field, #Int64 | | ||
+--------------------------------+ | ||
| -9223372036854774807 | | ||
+--------------------------------+ | ||
|
||
CREATE TABLE doubles(n DOUBLE, ts BIGINT TIME INDEX); | ||
|
||
MutateResult { success: 1, failure: 0 } | ||
|
||
INSERT INTO doubles (n, ts) VALUES (9007199254740992, 1), (1, 2), (1, 3), (0, 4); | ||
|
||
MutateResult { success: 4, failure: 0 } | ||
|
||
SELECT sum(n) from doubles; | ||
|
||
+----------------------------------+ | ||
| SUM(doubles.n), #Field, #Float64 | | ||
+----------------------------------+ | ||
| 9007199254740992 | | ||
+----------------------------------+ | ||
|
||
DROP TABLE bigints; | ||
|
||
MutateResult { success: 1, failure: 0 } | ||
|
||
DROP TABLE doubles; | ||
|
||
MutateResult { success: 1, failure: 0 } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
SELECT SUM(number) FROM numbers; | ||
|
||
SELECT SUM(1) FROM numbers; | ||
|
||
SELECT SUM(-1) FROM numbers; | ||
|
||
SELECT SUM(-1) FROM numbers WHERE number=-1; | ||
|
||
SELECT SUM(-1) FROM numbers WHERE number>10000 limit 1000; | ||
|
||
CREATE TABLE bigints(b BIGINT TIME INDEX); | ||
|
||
INSERT INTO bigints values (4611686018427387904), (4611686018427388904), (1); | ||
|
||
SELECT SUM(b) FROM bigints; | ||
|
||
CREATE TABLE doubles(n DOUBLE, ts BIGINT TIME INDEX); | ||
|
||
INSERT INTO doubles (n, ts) VALUES (9007199254740992, 1), (1, 2), (1, 3), (0, 4); | ||
|
||
SELECT sum(n) from doubles; | ||
|
||
DROP TABLE bigints; | ||
|
||
DROP TABLE doubles; |
File renamed without changes.
183 changes: 183 additions & 0 deletions
183
tests/cases/standalone/optimizer/filter_push_down.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
CREATE TABLE integers(i INTEGER, j BIGINT TIME INDEX); | ||
|
||
MutateResult { success: 1, failure: 0 } | ||
|
||
INSERT INTO integers VALUES (1, 1), (2, 2), (3, 3), (NULL, 4); | ||
|
||
MutateResult { success: 4, failure: 0 } | ||
|
||
SELECT i1.i, i2.i FROM integers i1, integers i2 WHERE i1.i=i2.i ORDER BY 1; | ||
|
||
+-------------------+-------------------+ | ||
| i, #Field, #Int32 | i, #Field, #Int32 | | ||
+-------------------+-------------------+ | ||
| 1 | 1 | | ||
| 2 | 2 | | ||
| 3 | 3 | | ||
+-------------------+-------------------+ | ||
|
||
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i1.i=i2.i AND i1.i>1 ORDER BY 1; | ||
|
||
+-------------------+-------------------+ | ||
| i, #Field, #Int32 | i, #Field, #Int32 | | ||
+-------------------+-------------------+ | ||
| 2 | 2 | | ||
| 3 | 3 | | ||
+-------------------+-------------------+ | ||
|
||
SELECT i1.i,i2.i,i3.i FROM integers i1, integers i2, integers i3 WHERE i1.i=i2.i AND i1.i=i3.i AND i1.i>1 ORDER BY 1; | ||
|
||
+-------------------+-------------------+-------------------+ | ||
| i, #Field, #Int32 | i, #Field, #Int32 | i, #Field, #Int32 | | ||
+-------------------+-------------------+-------------------+ | ||
| 2 | 2 | 2 | | ||
| 3 | 3 | 3 | | ||
+-------------------+-------------------+-------------------+ | ||
|
||
SELECT i1.i,i2.i FROM integers i1 JOIN integers i2 ON i1.i=i2.i WHERE i1.i>1 ORDER BY 1; | ||
|
||
+-------------------+-------------------+ | ||
| i, #Field, #Int32 | i, #Field, #Int32 | | ||
+-------------------+-------------------+ | ||
| 2 | 2 | | ||
| 3 | 3 | | ||
+-------------------+-------------------+ | ||
|
||
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=1 WHERE i1.i>2 ORDER BY 2; | ||
|
||
Failed to execute, error: Datanode { code: 1003, msg: "Failed to collect RecordBatches, source: Failed to poll stream, source: External error: Arrow error: External error: External error: Not expected to run ExecutionPlan more than once" } | ||
|
||
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE i2.i IS NOT NULL ORDER BY 2; | ||
|
||
++ | ||
++ | ||
|
||
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE i2.i>1 ORDER BY 2; | ||
|
||
++ | ||
++ | ||
|
||
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE CASE WHEN i2.i IS NULL THEN False ELSE True END ORDER BY 2; | ||
|
||
++ | ||
++ | ||
|
||
SELECT DISTINCT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE i2.i IS NULL ORDER BY 1; | ||
|
||
+-------------------+-------------------+ | ||
| i, #Field, #Int32 | i, #Field, #Int32 | | ||
+-------------------+-------------------+ | ||
| 1 | NULL | | ||
| 2 | NULL | | ||
| 3 | NULL | | ||
| NULL | NULL | | ||
+-------------------+-------------------+ | ||
|
||
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=1 WHERE i1.i=i2.i ORDER BY 1; | ||
|
||
+-------------------+-------------------+ | ||
| i, #Field, #Int32 | i, #Field, #Int32 | | ||
+-------------------+-------------------+ | ||
| 1 | 1 | | ||
| 2 | 2 | | ||
| 3 | 3 | | ||
+-------------------+-------------------+ | ||
|
||
SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) ORDER BY i; | ||
|
||
Failed to execute, error: Datanode { code: 3001, msg: "Failed to execute sql, source: Fail to create physical plan: This feature is not implemented: Physical plan does not support logical expression (<subquery>)" } | ||
|
||
SELECT * FROM integers WHERE i NOT IN ((SELECT i FROM integers WHERE i=1)) ORDER BY i; | ||
|
||
Failed to execute, error: Datanode { code: 3001, msg: "Failed to execute sql, source: Fail to create physical plan: This feature is not implemented: Physical plan does not support logical expression (<subquery>)" } | ||
|
||
SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) AND i<3 ORDER BY i; | ||
|
||
Failed to execute, error: Datanode { code: 3001, msg: "Failed to execute sql, source: Fail to create physical plan: This feature is not implemented: Physical plan does not support logical expression (<subquery>)" } | ||
|
||
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i IN ((SELECT i FROM integers)) AND i1.i=i2.i ORDER BY 1; | ||
|
||
Failed to execute, error: Datanode { code: 3001, msg: "Failed to execute sql, source: Fail to create physical plan: This feature is not implemented: Physical plan does not support logical expression (<subquery>)" } | ||
|
||
SELECT * FROM integers i1 WHERE EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i; | ||
|
||
+-------------------+-----------------------+ | ||
| i, #Field, #Int32 | j, #Timestamp, #Int64 | | ||
+-------------------+-----------------------+ | ||
| 1 | 1 | | ||
| 2 | 2 | | ||
| 3 | 3 | | ||
+-------------------+-----------------------+ | ||
|
||
SELECT * FROM integers i1 WHERE NOT EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i; | ||
|
||
+-------------------+-----------------------+ | ||
| i, #Field, #Int32 | j, #Timestamp, #Int64 | | ||
+-------------------+-----------------------+ | ||
| NULL | 4 | | ||
+-------------------+-----------------------+ | ||
|
||
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i1.i=(SELECT i FROM integers WHERE i1.i=i) AND i1.i=i2.i ORDER BY i1.i; | ||
|
||
Failed to execute, error: Datanode { code: 3001, msg: "Failed to execute sql, source: Fail to create physical plan: This feature is not implemented: Physical plan does not support logical expression (<subquery>)" } | ||
|
||
SELECT * FROM (SELECT i1.i AS a, i2.i AS b FROM integers i1, integers i2) a1 WHERE a=b ORDER BY 1; | ||
|
||
+-------------------+-------------------+ | ||
| a, #Field, #Int32 | b, #Field, #Int32 | | ||
+-------------------+-------------------+ | ||
| 1 | 1 | | ||
| 2 | 2 | | ||
| 3 | 3 | | ||
+-------------------+-------------------+ | ||
|
||
SELECT * FROM (SELECT i1.i=i2.i AS cond FROM integers i1, integers i2) a1 WHERE cond ORDER BY 1; | ||
|
||
+------------------------+ | ||
| cond, #Field, #Boolean | | ||
+------------------------+ | ||
| true | | ||
| true | | ||
| true | | ||
+------------------------+ | ||
|
||
SELECT * FROM (SELECT DISTINCT i1.i AS a, i2.i AS b FROM integers i1, integers i2) res WHERE a=1 AND b=3; | ||
|
||
+-------------------+-------------------+ | ||
| a, #Field, #Int32 | b, #Field, #Int32 | | ||
+-------------------+-------------------+ | ||
| 1 | 3 | | ||
+-------------------+-------------------+ | ||
|
||
SELECT i FROM (SELECT * FROM integers i1 UNION SELECT * FROM integers i2) a WHERE i=3; | ||
|
||
+-------------------+ | ||
| i, #Field, #Int32 | | ||
+-------------------+ | ||
| 3 | | ||
+-------------------+ | ||
|
||
SELECT * FROM (SELECT i1.i AS a, i2.i AS b, row_number() OVER (ORDER BY i1.i, i2.i) FROM integers i1, integers i2 WHERE i1.i IS NOT NULL AND i2.i IS NOT NULL) a1 WHERE a=b ORDER BY 1; | ||
|
||
+-------------------+-------------------+-------------------------------+ | ||
| a, #Field, #Int32 | b, #Field, #Int32 | ROW_NUMBER(), #Field, #Uint64 | | ||
+-------------------+-------------------+-------------------------------+ | ||
| 1 | 1 | 1 | | ||
| 2 | 2 | 5 | | ||
| 3 | 3 | 9 | | ||
+-------------------+-------------------+-------------------------------+ | ||
|
||
SELECT * FROM (SELECT 0=1 AS cond FROM integers i1, integers i2) a1 WHERE cond ORDER BY 1; | ||
|
||
++ | ||
++ | ||
|
||
SELECT * FROM (SELECT 0=1 AS cond FROM integers i1, integers i2 GROUP BY 1) a1 WHERE cond ORDER BY 1; | ||
|
||
++ | ||
++ | ||
|
||
DROP TABLE integers; | ||
|
||
MutateResult { success: 1, failure: 0 } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
CREATE TABLE integers(i INTEGER, j BIGINT TIME INDEX); | ||
|
||
INSERT INTO integers VALUES (1, 1), (2, 2), (3, 3), (NULL, 4); | ||
|
||
SELECT i1.i, i2.i FROM integers i1, integers i2 WHERE i1.i=i2.i ORDER BY 1; | ||
|
||
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i1.i=i2.i AND i1.i>1 ORDER BY 1; | ||
|
||
SELECT i1.i,i2.i,i3.i FROM integers i1, integers i2, integers i3 WHERE i1.i=i2.i AND i1.i=i3.i AND i1.i>1 ORDER BY 1; | ||
|
||
SELECT i1.i,i2.i FROM integers i1 JOIN integers i2 ON i1.i=i2.i WHERE i1.i>1 ORDER BY 1; | ||
|
||
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=1 WHERE i1.i>2 ORDER BY 2; | ||
|
||
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE i2.i IS NOT NULL ORDER BY 2; | ||
|
||
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE i2.i>1 ORDER BY 2; | ||
|
||
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE CASE WHEN i2.i IS NULL THEN False ELSE True END ORDER BY 2; | ||
|
||
SELECT DISTINCT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE i2.i IS NULL ORDER BY 1; | ||
|
||
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=1 WHERE i1.i=i2.i ORDER BY 1; | ||
|
||
SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) ORDER BY i; | ||
|
||
SELECT * FROM integers WHERE i NOT IN ((SELECT i FROM integers WHERE i=1)) ORDER BY i; | ||
|
||
SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) AND i<3 ORDER BY i; | ||
|
||
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i IN ((SELECT i FROM integers)) AND i1.i=i2.i ORDER BY 1; | ||
|
||
SELECT * FROM integers i1 WHERE EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i; | ||
|
||
SELECT * FROM integers i1 WHERE NOT EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i; | ||
|
||
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i1.i=(SELECT i FROM integers WHERE i1.i=i) AND i1.i=i2.i ORDER BY i1.i; | ||
|
||
SELECT * FROM (SELECT i1.i AS a, i2.i AS b FROM integers i1, integers i2) a1 WHERE a=b ORDER BY 1; | ||
|
||
SELECT * FROM (SELECT i1.i=i2.i AS cond FROM integers i1, integers i2) a1 WHERE cond ORDER BY 1; | ||
|
||
SELECT * FROM (SELECT DISTINCT i1.i AS a, i2.i AS b FROM integers i1, integers i2) res WHERE a=1 AND b=3; | ||
|
||
SELECT i FROM (SELECT * FROM integers i1 UNION SELECT * FROM integers i2) a WHERE i=3; | ||
|
||
SELECT * FROM (SELECT i1.i AS a, i2.i AS b, row_number() OVER (ORDER BY i1.i, i2.i) FROM integers i1, integers i2 WHERE i1.i IS NOT NULL AND i2.i IS NOT NULL) a1 WHERE a=b ORDER BY 1; | ||
|
||
SELECT * FROM (SELECT 0=1 AS cond FROM integers i1, integers i2) a1 WHERE cond ORDER BY 1; | ||
|
||
SELECT * FROM (SELECT 0=1 AS cond FROM integers i1, integers i2 GROUP BY 1) a1 WHERE cond ORDER BY 1; | ||
|
||
DROP TABLE integers; |