diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-10 09:23:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-08-10 09:23:46 +0000 |
commit | 5dde903f4f6659e384287a3e508b9f369c5a2ba3 (patch) | |
tree | 05cd2920d82f0023f6ac695dbb6eaeef64608401 /tests/fixtures/optimizer/optimizer.sql | |
parent | Adding upstream version 17.9.1. (diff) | |
download | sqlglot-5dde903f4f6659e384287a3e508b9f369c5a2ba3.tar.xz sqlglot-5dde903f4f6659e384287a3e508b9f369c5a2ba3.zip |
Adding upstream version 17.11.0.upstream/17.11.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/fixtures/optimizer/optimizer.sql')
-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"; |