diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-03 09:12:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-03 09:12:24 +0000 |
commit | 98d5537435b2951b36c45f1fda667fa27c165794 (patch) | |
tree | d26b4dfa6cf91847100fe10a94a04dcc2ad36a86 /tests/fixtures/optimizer/qualify_columns.sql | |
parent | Adding upstream version 11.5.2. (diff) | |
download | sqlglot-98d5537435b2951b36c45f1fda667fa27c165794.tar.xz sqlglot-98d5537435b2951b36c45f1fda667fa27c165794.zip |
Adding upstream version 11.7.1.upstream/11.7.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/fixtures/optimizer/qualify_columns.sql | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/fixtures/optimizer/qualify_columns.sql b/tests/fixtures/optimizer/qualify_columns.sql index 74e2d0a..3013bba 100644 --- a/tests/fixtures/optimizer/qualify_columns.sql +++ b/tests/fixtures/optimizer/qualify_columns.sql @@ -131,6 +131,14 @@ SELECT DATE_TRUNC(x.a, MONTH) AS a FROM x AS x; SELECT x FROM READ_PARQUET('path.parquet', hive_partition=1); SELECT _q_0.x AS x FROM READ_PARQUET('path.parquet', hive_partition = 1) AS _q_0; +# execute: false +select * from (values (1, 2)); +SELECT _q_0._col_0 AS _col_0, _q_0._col_1 AS _col_1 FROM (VALUES (1, 2)) AS _q_0(_col_0, _col_1); + +# execute: false +select * from (values (1, 2)) x; +SELECT x._col_0 AS _col_0, x._col_1 AS _col_1 FROM (VALUES (1, 2)) AS x(_col_0, _col_1); + -------------------------------------- -- Derived tables -------------------------------------- @@ -317,6 +325,21 @@ SELECT COALESCE(y.b, z.b) AS b, COALESCE(y.c, z.c) AS c FROM y AS y JOIN z AS z SELECT * FROM y JOIN z USING(b, c) WHERE b = 2 AND c = 3; SELECT COALESCE(y.b, z.b) AS b, COALESCE(y.c, z.c) AS c FROM y AS y JOIN z AS z ON y.b = z.b AND y.c = z.c WHERE COALESCE(y.b, z.b) = 2 AND COALESCE(y.c, z.c) = 3; +-- We can safely convert `b` to `x.b` in the following two queries, because the original queries +-- would be invalid if `b` also existed in `t`'s schema (which we don't know), due to ambiguity. + +# execute: false +SELECT b FROM x JOIN t USING(a); +SELECT x.b AS b FROM x AS x JOIN t AS t ON x.a = t.a; + +# execute: false +SELECT b FROM t JOIN x USING(a); +SELECT x.b AS b FROM t AS t JOIN x AS x ON t.a = x.a; + +# execute: false +SELECT a FROM t1 JOIN t2 USING(a); +SELECT COALESCE(t1.a, t2.a) AS a FROM t1 AS t1 JOIN t2 AS t2 ON t1.a = t2.a; + -------------------------------------- -- Hint with table reference -------------------------------------- |