diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-10 09:23:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-10 09:23:50 +0000 |
commit | 4cc7d5a6dcda8f275b4156a9a23bbe5380be1b53 (patch) | |
tree | 1084b1a2dd9f2782031b4aa79608db08968a5837 /tests/fixtures/optimizer/optimizer.sql | |
parent | Releasing debian version 17.9.1-1. (diff) | |
download | sqlglot-4cc7d5a6dcda8f275b4156a9a23bbe5380be1b53.tar.xz sqlglot-4cc7d5a6dcda8f275b4156a9a23bbe5380be1b53.zip |
Merging upstream version 17.11.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/fixtures/optimizer/optimizer.sql | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/fixtures/optimizer/optimizer.sql b/tests/fixtures/optimizer/optimizer.sql index 981e052..74572d2 100644 --- a/tests/fixtures/optimizer/optimizer.sql +++ b/tests/fixtures/optimizer/optimizer.sql @@ -907,3 +907,40 @@ JOIN "x" AS "x" ON "y"."b" = "x"."b" GROUP BY "x"."a"; + +# title: select * from a cte, which had one of its two columns aliased +WITH cte(x, y) AS (SELECT 1, 2) SELECT * FROM cte AS cte(a); +WITH "cte" AS ( + SELECT + 1 AS "x", + 2 AS "y" +) +SELECT + "cte"."a" AS "a", + "cte"."y" AS "y" +FROM "cte" AS "cte"("a"); + +# title: select single column from a cte using its alias +WITH cte(x) AS (SELECT 1) SELECT a FROM cte AS cte(a); +WITH "cte" AS ( + SELECT + 1 AS "x" +) +SELECT + "cte"."a" AS "a" +FROM "cte" AS "cte"("a"); + +# title: joined ctes with a "using" clause, one of which has had its column aliased +WITH m(a) AS (SELECT 1), n(b) AS (SELECT 1) SELECT * FROM m JOIN n AS foo(a) USING (a); +WITH "m" AS ( + SELECT + 1 AS "a" +), "n" AS ( + SELECT + 1 AS "b" +) +SELECT + COALESCE("m"."a", "foo"."a") AS "a" +FROM "m" +JOIN "n" AS "foo"("a") + ON "m"."a" = "foo"."a"; |