summaryrefslogtreecommitdiffstats
path: root/tests/fixtures/optimizer/optimizer.sql
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-03-19 10:22:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-03-19 10:22:04 +0000
commit57c3067868d0a1da90ec0f2201dd91f031241274 (patch)
tree3b16819683e27ccbc7e7726675ab8d3e978fc8aa /tests/fixtures/optimizer/optimizer.sql
parentAdding upstream version 11.3.6. (diff)
downloadsqlglot-57c3067868d0a1da90ec0f2201dd91f031241274.tar.xz
sqlglot-57c3067868d0a1da90ec0f2201dd91f031241274.zip
Adding upstream version 11.4.1.upstream/11.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.sql31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/fixtures/optimizer/optimizer.sql b/tests/fixtures/optimizer/optimizer.sql
index a14e325..0b5504d 100644
--- a/tests/fixtures/optimizer/optimizer.sql
+++ b/tests/fixtures/optimizer/optimizer.sql
@@ -386,6 +386,29 @@ SELECT
"x"."b" + 1 AS "c"
FROM "x" AS "x";
+# title: unqualified struct element is selected in the outer query
+# execute: false
+WITH "cte" AS (
+ SELECT
+ FROM_JSON("value", 'STRUCT<f1: STRUCT<f2: STRUCT<f3: STRUCT<f4: STRING>>>>') AS "struct"
+ FROM "tbl"
+) SELECT "struct"."f1"."f2"."f3"."f4" AS "f4" FROM "cte";
+SELECT
+ FROM_JSON("tbl"."value", 'STRUCT<f1: STRUCT<f2: STRUCT<f3: STRUCT<f4: STRING>>>>')."f1"."f2"."f3"."f4" AS "f4"
+FROM "tbl" AS "tbl";
+
+# title: qualified struct element is selected in the outer query
+# execute: false
+WITH "cte" AS (
+ SELECT
+ FROM_JSON("value", 'STRUCT<f1: STRUCT<f2: INTEGER>, STRUCT<f3: STRING>>') AS "struct"
+ FROM "tbl"
+) SELECT "cte"."struct"."f1"."f2" AS "f2", "cte"."struct"."f1"."f3" AS "f3" FROM "cte";
+SELECT
+ FROM_JSON("tbl"."value", 'STRUCT<f1: STRUCT<f2: INTEGER>, STRUCT<f3: STRING>>')."f1"."f2" AS "f2",
+ FROM_JSON("tbl"."value", 'STRUCT<f1: STRUCT<f2: INTEGER>, STRUCT<f3: STRING>>')."f1"."f3" AS "f3"
+FROM "tbl" AS "tbl";
+
# title: left join doesnt push down predicate to join in merge subqueries
# execute: false
SELECT
@@ -430,3 +453,11 @@ LEFT JOIN "unlocked" AS "unlocked"
WHERE
CASE WHEN "unlocked"."company_id" IS NULL THEN 0 ELSE 1 END = FALSE
AND NOT "company_table_2"."id" IS NULL;
+
+# title: db.table alias clash
+# execute: false
+select * from db1.tbl, db2.tbl;
+SELECT
+ *
+FROM "db1"."tbl" AS "tbl"
+CROSS JOIN "db2"."tbl" AS "tbl_2";