diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:12:52 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 08:12:52 +0000 |
commit | a1f10f8d39404d9bae42a64efaf505fa12f34c1a (patch) | |
tree | 9eb894268f2a145aa9d42b1726a555ab1359810f /tests/fixtures/optimizer | |
parent | Adding upstream version 25.8.1. (diff) | |
download | sqlglot-upstream/25.16.1.tar.xz sqlglot-upstream/25.16.1.zip |
Adding upstream version 25.16.1.upstream/25.16.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/fixtures/optimizer')
-rw-r--r-- | tests/fixtures/optimizer/annotate_types.sql | 7 | ||||
-rw-r--r-- | tests/fixtures/optimizer/canonicalize.sql | 4 | ||||
-rw-r--r-- | tests/fixtures/optimizer/qualify_columns.sql | 15 |
3 files changed, 26 insertions, 0 deletions
diff --git a/tests/fixtures/optimizer/annotate_types.sql b/tests/fixtures/optimizer/annotate_types.sql index 589f0ec..0a5fc22 100644 --- a/tests/fixtures/optimizer/annotate_types.sql +++ b/tests/fixtures/optimizer/annotate_types.sql @@ -15,6 +15,13 @@ bool; null; null; + +null and false; +bool; + +null + 1; +int; + CASE WHEN x THEN NULL ELSE 1 END; INT; diff --git a/tests/fixtures/optimizer/canonicalize.sql b/tests/fixtures/optimizer/canonicalize.sql index e4c78b7..66c6c95 100644 --- a/tests/fixtures/optimizer/canonicalize.sql +++ b/tests/fixtures/optimizer/canonicalize.sql @@ -52,6 +52,10 @@ SELECT "x"."a" AS "a" FROM "x" AS "x" WHERE CASE WHEN COALESCE("x"."b" <> 0, 1 < DATE('2023-01-01'); CAST('2023-01-01' AS DATE); +-- Some dialects only allow dates +DATE('2023-01-01 00:00:00'); +DATE('2023-01-01 00:00:00'); + TIMESTAMP('2023-01-01'); CAST('2023-01-01' AS TIMESTAMP); diff --git a/tests/fixtures/optimizer/qualify_columns.sql b/tests/fixtures/optimizer/qualify_columns.sql index 444a8e0..7d58908 100644 --- a/tests/fixtures/optimizer/qualify_columns.sql +++ b/tests/fixtures/optimizer/qualify_columns.sql @@ -343,6 +343,11 @@ WITH tbl1 AS (SELECT STRUCT(1 AS col1, Struct(5 AS col1)) AS col) SELECT tbl1.co WITH tbl1 AS (SELECT STRUCT(1 AS col1, 2 AS col1) AS col) SELECT tbl1.col.* FROM tbl1; WITH tbl1 AS (SELECT STRUCT(1 AS col1, 2 AS col1) AS col) SELECT tbl1.col.* FROM tbl1 AS tbl1; +# title: CSV files are not scanned by default +# execute: false +SELECT * FROM READ_CSV('file.csv'); +SELECT * FROM READ_CSV('file.csv') AS _q_0; + -------------------------------------- -- CTEs -------------------------------------- @@ -655,6 +660,16 @@ SELECT x.a + x.b AS f, x.a + x.b AS _col_1, x.a + x.b + 5 AS _col_2 FROM x AS x; SELECT a, SUM(b) AS c, SUM(c) OVER(PARTITION BY a) AS d from x group by 1 ORDER BY a; SELECT x.a AS a, SUM(x.b) AS c, SUM(SUM(x.b)) OVER (PARTITION BY x.a) AS d FROM x AS x GROUP BY x.a ORDER BY a; +# title: we can't expand aliases corresponding to recursive CTE columns (CTE names output columns) +# execute: false +WITH RECURSIVE t(c) AS (SELECT 1 AS c UNION ALL SELECT c + 1 AS c FROM t WHERE c <= 10) SELECT c FROM t; +WITH RECURSIVE t(c) AS (SELECT 1 AS c UNION ALL SELECT t.c + 1 AS c FROM t AS t WHERE t.c <= 10) SELECT t.c AS c FROM t AS t; + +# title: we can't expand aliases corresponding to recursive CTE columns (CTE doesn't name output columns) +# execute: false +WITH RECURSIVE t AS (SELECT 1 AS c UNION ALL SELECT c + 1 AS c FROM t WHERE c <= 10) SELECT c FROM t; +WITH RECURSIVE t AS (SELECT 1 AS c UNION ALL SELECT t.c + 1 AS c FROM t AS t WHERE t.c <= 10) SELECT t.c AS c FROM t AS t; + -------------------------------------- -- Wrapped tables / join constructs -------------------------------------- |