diff options
Diffstat (limited to 'tests/fixtures/optimizer/optimizer.sql')
-rw-r--r-- | tests/fixtures/optimizer/optimizer.sql | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/fixtures/optimizer/optimizer.sql b/tests/fixtures/optimizer/optimizer.sql index 4b58ea5..14f5cfe 100644 --- a/tests/fixtures/optimizer/optimizer.sql +++ b/tests/fixtures/optimizer/optimizer.sql @@ -806,3 +806,87 @@ LEFT JOIN ( ON "y"."c" = "z"."c" ) ON "x"."b" = "y"."b"; + +# title: select * from wrapped subquery +# execute: false +SELECT * FROM ((SELECT * FROM tbl)); +WITH "_q_0" AS ( + SELECT + * + FROM "tbl" AS "tbl" +) +SELECT + * +FROM ( + "_q_0" AS "_q_0" +); + +# title: select * from wrapped subquery joined to a table (known schema) +SELECT * FROM ((SELECT * FROM x) INNER JOIN y ON a = c); +SELECT + "x"."a" AS "a", + "x"."b" AS "b", + "y"."b" AS "b", + "y"."c" AS "c" +FROM ( + "x" AS "x" + JOIN "y" AS "y" + ON "x"."a" = "y"."c" +); + +# title: select * from wrapped subquery joined to a table (unknown schema) +# execute: false +SELECT * FROM ((SELECT c FROM t1) JOIN t2); +WITH "_q_0" AS ( + SELECT + "t1"."c" AS "c" + FROM "t1" AS "t1" +) +SELECT + * +FROM ( + "_q_0" AS "_q_0" + CROSS JOIN "t2" AS "t2" +); + +# title: select specific columns from wrapped subquery joined to a table +SELECT b FROM ((SELECT a FROM x) INNER JOIN y ON a = b); +SELECT + "y"."b" AS "b" +FROM ( + "x" AS "x" + JOIN "y" AS "y" + ON "x"."a" = "y"."b" +); + +# title: select * from wrapped join of subqueries (unknown schema) +# execute: false +SELECT * FROM ((SELECT * FROM t1) JOIN (SELECT * FROM t2)); +WITH "_q_0" AS ( + SELECT + * + FROM "t1" AS "t1" +), "_q_1" AS ( + SELECT + * + FROM "t2" AS "t2" +) +SELECT + * +FROM ( + "_q_0" AS "_q_0" + CROSS JOIN "_q_1" AS "_q_1" +); + +# title: select * from wrapped join of subqueries (known schema) +SELECT * FROM ((SELECT * FROM x) INNER JOIN (SELECT * FROM y) ON a = c); +SELECT + "x"."a" AS "a", + "x"."b" AS "b", + "y"."b" AS "b", + "y"."c" AS "c" +FROM ( + "x" AS "x" + JOIN "y" AS "y" + ON "x"."a" = "y"."c" +); |