From 918abde014f9e5c75dfbe21110c379f7f70435c9 Mon Sep 17 00:00:00 2001
From: Daniel Baumann <daniel.baumann@progress-linux.org>
Date: Sun, 12 Feb 2023 11:06:28 +0100
Subject: Merging upstream version 11.0.1.

Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
---
 tests/fixtures/optimizer/optimizer.sql | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

(limited to 'tests/fixtures/optimizer/optimizer.sql')

diff --git a/tests/fixtures/optimizer/optimizer.sql b/tests/fixtures/optimizer/optimizer.sql
index 664b3c7..9c14ec1 100644
--- a/tests/fixtures/optimizer/optimizer.sql
+++ b/tests/fixtures/optimizer/optimizer.sql
@@ -1,14 +1,20 @@
 # title: lateral
 # execute: false
 SELECT a, m FROM z LATERAL VIEW EXPLODE([1, 2]) q AS m;
+WITH "z_2" AS (
+  SELECT
+    "z"."a" AS "a"
+  FROM "z" AS "z"
+)
 SELECT
   "z"."a" AS "a",
   "q"."m" AS "m"
-FROM "z" AS "z"
+FROM "z_2" AS "z"
 LATERAL VIEW
 EXPLODE(ARRAY(1, 2)) q AS "m";
 
 # title: unnest
+# execute: false
 SELECT x FROM UNNEST([1, 2]) AS q(x, y);
 SELECT
   "q"."x" AS "x"
@@ -369,3 +375,18 @@ SELECT
 FROM "x" AS "x"
 RIGHT JOIN "y_2" AS "y"
   ON "x"."a" = "y"."b";
+
+
+# title: lateral column alias reference
+SELECT x.a + 1 AS c, c + 1 AS d FROM x;
+SELECT
+  "x"."a" + 1 AS "c",
+  "x"."a" + 2 AS "d"
+FROM "x" AS "x";
+
+# title: column reference takes priority over lateral column alias reference
+SELECT x.a + 1 AS b, b + 1 AS c FROM x;
+SELECT
+  "x"."a" + 1 AS "b",
+  "x"."b" + 1 AS "c"
+FROM "x" AS "x";
-- 
cgit v1.2.3

