From bdf5cc7bdd5ec93dc928d81e286f7b1e678ba19d Mon Sep 17 00:00:00 2001
From: Daniel Baumann <daniel.baumann@progress-linux.org>
Date: Wed, 13 Sep 2023 11:17:40 +0200
Subject: Merging upstream version 18.4.1.

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

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

diff --git a/tests/fixtures/optimizer/merge_subqueries.sql b/tests/fixtures/optimizer/merge_subqueries.sql
index b89e2fb..eec8a73 100644
--- a/tests/fixtures/optimizer/merge_subqueries.sql
+++ b/tests/fixtures/optimizer/merge_subqueries.sql
@@ -310,6 +310,21 @@ FROM
   t1;
 SELECT x.a AS a, x.b AS b, ROW_NUMBER() OVER (PARTITION BY x.a ORDER BY x.a) AS row_num FROM x AS x;
 
+# title: Don't merge window functions, inner table is aliased in outer query
+with t1 as (
+  SELECT
+    ROW_NUMBER() OVER (PARTITION BY x.a ORDER BY x.a) as row_num
+  FROM
+    x
+)
+SELECT
+  t2.row_num
+FROM
+  t1 AS t2
+WHERE
+  t2.row_num = 2;
+WITH t1 AS (SELECT ROW_NUMBER() OVER (PARTITION BY x.a ORDER BY x.a) AS row_num FROM x AS x) SELECT t2.row_num AS row_num FROM t1 AS t2 WHERE t2.row_num = 2;
+
 # title: Values Test
 # dialect: spark
 WITH t1 AS (
-- 
cgit v1.2.3

