summaryrefslogtreecommitdiffstats
path: root/tests/fixtures/optimizer/optimizer.sql
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-14 05:42:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-07-14 05:42:58 +0000
commitb0bf1ad1a196585c2d31bc38c554637fc4e2eec9 (patch)
tree2fe11cc45ff45169984b4dfb7b64661d1897ad9c /tests/fixtures/optimizer/optimizer.sql
parentAdding upstream version 17.3.0. (diff)
downloadsqlglot-b0bf1ad1a196585c2d31bc38c554637fc4e2eec9.tar.xz
sqlglot-b0bf1ad1a196585c2d31bc38c554637fc4e2eec9.zip
Adding upstream version 17.4.1.upstream/17.4.1
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.sql105
1 files changed, 105 insertions, 0 deletions
diff --git a/tests/fixtures/optimizer/optimizer.sql b/tests/fixtures/optimizer/optimizer.sql
index 38e64d7..4b58ea5 100644
--- a/tests/fixtures/optimizer/optimizer.sql
+++ b/tests/fixtures/optimizer/optimizer.sql
@@ -701,3 +701,108 @@ SELECT
"x"."a" * "x"."b" - "x"."b"
) AS "f"
FROM "x" AS "x";
+
+# title: wrapped table without alias
+# execute: false
+SELECT * FROM (tbl);
+SELECT
+ *
+FROM (
+ "tbl" AS "tbl"
+);
+
+# title: wrapped table with alias
+# execute: false
+SELECT * FROM (tbl AS tbl);
+SELECT
+ *
+FROM (
+ "tbl" AS "tbl"
+);
+
+# title: wrapped join of tables without alias
+SELECT a, c FROM (x LEFT JOIN y ON a = c);
+SELECT
+ "x"."a" AS "a",
+ "y"."c" AS "c"
+FROM (
+ "x" AS "x"
+ LEFT JOIN "y" AS "y"
+ ON "x"."a" = "y"."c"
+);
+
+# title: wrapped join of tables with alias
+# execute: false
+SELECT a, c FROM (x LEFT JOIN y ON a = c) AS t;
+SELECT
+ "x"."a" AS "a",
+ "y"."c" AS "c"
+FROM "x" AS "x"
+LEFT JOIN "y" AS "y"
+ ON "x"."a" = "y"."c";
+
+# title: chained wrapped joins without aliases
+# execute: false
+SELECT * FROM ((a CROSS JOIN ((b CROSS JOIN c) CROSS JOIN (d CROSS JOIN e))));
+SELECT
+ *
+FROM (
+ (
+ "a" AS "a"
+ CROSS JOIN (
+ (
+ "b" AS "b"
+ CROSS JOIN "c" AS "c"
+ )
+ CROSS JOIN (
+ "d" AS "d"
+ CROSS JOIN "e" AS "e"
+ )
+ )
+ )
+);
+
+# title: chained wrapped joins with aliases
+# execute: false
+SELECT * FROM ((a AS foo CROSS JOIN b AS bar) CROSS JOIN c AS baz);
+SELECT
+ *
+FROM (
+ (
+ "a" AS "foo"
+ CROSS JOIN "b" AS "bar"
+ )
+ CROSS JOIN "c" AS "baz"
+);
+
+# title: table joined with join construct
+SELECT x.a, y.b, z.c FROM x LEFT JOIN (y INNER JOIN z ON y.c = z.c) ON x.b = y.b;
+SELECT
+ "x"."a" AS "a",
+ "y"."b" AS "b",
+ "z"."c" AS "c"
+FROM "x" AS "x"
+LEFT JOIN (
+ "y" AS "y"
+ JOIN "z" AS "z"
+ ON "y"."c" = "z"."c"
+)
+ ON "x"."b" = "y"."b";
+
+# title: select * from table joined with join construct
+# execute: false
+SELECT * FROM x LEFT JOIN (y INNER JOIN z ON y.c = z.c) ON x.b = y.b;
+SELECT
+ "y"."b" AS "b",
+ "y"."c" AS "c",
+ "z"."a" AS "a",
+ "z"."c" AS "c",
+ "x"."a" AS "a",
+ "x"."b" AS "b"
+FROM "x" AS "x"
+LEFT JOIN (
+ "y" AS "y"
+ JOIN "z" AS "z"
+ ON "y"."c" = "z"."c"
+)
+ ON "x"."b" = "y"."b";