From 74b38d30f43f7005428e09fa80508c5f21324c99 Mon Sep 17 00:00:00 2001
From: Daniel Baumann <daniel.baumann@progress-linux.org>
Date: Mon, 10 Oct 2022 13:29:00 +0200
Subject: Adding upstream version 6.3.1.

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

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

diff --git a/tests/fixtures/optimizer/qualify_columns.sql b/tests/fixtures/optimizer/qualify_columns.sql
index f848e7a..83a3bf8 100644
--- a/tests/fixtures/optimizer/qualify_columns.sql
+++ b/tests/fixtures/optimizer/qualify_columns.sql
@@ -19,38 +19,49 @@ SELECT x.a AS a FROM x AS x;
 SELECT a AS b FROM x;
 SELECT x.a AS b FROM x AS x;
 
+# execute: false
 SELECT 1, 2 FROM x;
 SELECT 1 AS "_col_0", 2 AS "_col_1" FROM x AS x;
 
+# execute: false
 SELECT a + b FROM x;
 SELECT x.a + x.b AS "_col_0" FROM x AS x;
 
-SELECT a + b FROM x;
-SELECT x.a + x.b AS "_col_0" FROM x AS x;
-
+# execute: false
 SELECT a, SUM(b) FROM x WHERE a > 1 AND b > 1 GROUP BY a;
 SELECT x.a AS a, SUM(x.b) AS "_col_1" FROM x AS x WHERE x.a > 1 AND x.b > 1 GROUP BY x.a;
 
 SELECT a AS j, b FROM x ORDER BY j;
 SELECT x.a AS j, x.b AS b FROM x AS x ORDER BY j;
 
-SELECT a AS j, b FROM x GROUP BY j;
-SELECT x.a AS j, x.b AS b FROM x AS x GROUP BY x.a;
+SELECT a AS j, b AS a FROM x ORDER BY 1;
+SELECT x.a AS j, x.b AS a FROM x AS x ORDER BY x.a;
+
+SELECT SUM(a) AS c, SUM(b) AS d FROM x ORDER BY 1, 2;
+SELECT SUM(x.a) AS c, SUM(x.b) AS d FROM x AS x ORDER BY SUM(x.a), SUM(x.b);
+
+# execute: false
+SELECT SUM(a), SUM(b) AS c FROM x ORDER BY 1, 2;
+SELECT SUM(x.a) AS "_col_0", SUM(x.b) AS c FROM x AS x ORDER BY SUM(x.a), SUM(x.b);
+
+SELECT a AS j, b FROM x GROUP BY j, b;
+SELECT x.a AS j, x.b AS b FROM x AS x GROUP BY x.a, x.b;
 
 SELECT a, b FROM x GROUP BY 1, 2;
 SELECT x.a AS a, x.b AS b FROM x AS x GROUP BY x.a, x.b;
 
 SELECT a, b FROM x ORDER BY 1, 2;
-SELECT x.a AS a, x.b AS b FROM x AS x ORDER BY a, b;
+SELECT x.a AS a, x.b AS b FROM x AS x ORDER BY x.a, x.b;
 
+# execute: false
 SELECT DATE(a), DATE(b) AS c FROM x GROUP BY 1, 2;
 SELECT DATE(x.a) AS "_col_0", DATE(x.b) AS c FROM x AS x GROUP BY DATE(x.a), DATE(x.b);
 
-SELECT x.a AS c FROM x JOIN y ON x.b = y.b GROUP BY c;
-SELECT x.a AS c FROM x AS x JOIN y AS y ON x.b = y.b GROUP BY y.c;
+SELECT SUM(x.a) AS c FROM x JOIN y ON x.b = y.b GROUP BY c;
+SELECT SUM(x.a) AS c FROM x AS x JOIN y AS y ON x.b = y.b GROUP BY y.c;
 
-SELECT DATE(x.a) AS d FROM x JOIN y ON x.b = y.b GROUP BY d;
-SELECT DATE(x.a) AS d FROM x AS x JOIN y AS y ON x.b = y.b GROUP BY DATE(x.a);
+SELECT COALESCE(x.a) AS d FROM x JOIN y ON x.b = y.b GROUP BY d;
+SELECT COALESCE(x.a) AS d FROM x AS x JOIN y AS y ON x.b = y.b GROUP BY COALESCE(x.a);
 
 SELECT a AS a, b FROM x ORDER BY a;
 SELECT x.a AS a, x.b AS b FROM x AS x ORDER BY a;
@@ -69,6 +80,7 @@ SELECT ROW_NUMBER() OVER (PARTITION BY x.a ORDER BY x.b) AS row_num FROM x AS x
 SELECT x.b, x.a FROM x LEFT JOIN y ON x.b = y.b QUALIFY ROW_NUMBER() OVER(PARTITION BY x.b ORDER BY x.a DESC) = 1;
 SELECT x.b AS b, x.a AS a FROM x AS x LEFT JOIN y AS y ON x.b = y.b QUALIFY ROW_NUMBER() OVER (PARTITION BY x.b ORDER BY x.a DESC) = 1;
 
+# execute: false
 SELECT AGGREGATE(ARRAY(a, x.b), 0, (x, acc) -> x + acc + a) AS sum_agg FROM x;
 SELECT AGGREGATE(ARRAY(x.a, x.b), 0, (x, acc) -> x + acc + x.a) AS sum_agg FROM x AS x;
 
@@ -93,8 +105,8 @@ SELECT "_q_0".a AS a FROM (SELECT x.a AS a FROM x AS x) AS "_q_0";
 SELECT a FROM (SELECT a FROM (SELECT a FROM x));
 SELECT "_q_1".a AS a FROM (SELECT "_q_0".a AS a FROM (SELECT x.a AS a FROM x AS x) AS "_q_0") AS "_q_1";
 
-SELECT x.a FROM x AS x JOIN (SELECT * FROM x);
-SELECT x.a AS a FROM x AS x JOIN (SELECT x.a AS a, x.b AS b FROM x AS x) AS "_q_0";
+SELECT x.a FROM x AS x JOIN (SELECT * FROM x) AS y ON x.a = y.a;
+SELECT x.a AS a FROM x AS x JOIN (SELECT x.a AS a, x.b AS b FROM x AS x) AS y ON x.a = y.a;
 
 --------------------------------------
 -- Joins
@@ -123,6 +135,7 @@ SELECT "_q_0".a AS a FROM (SELECT x.a AS a FROM x AS x UNION SELECT x.a AS a FRO
 SELECT a FROM x WHERE b IN (SELECT c FROM y);
 SELECT x.a AS a FROM x AS x WHERE x.b IN (SELECT y.c AS c FROM y AS y);
 
+# execute: false
 SELECT (SELECT c FROM y) FROM x;
 SELECT (SELECT y.c AS c FROM y AS y) AS "_col_0" FROM x AS x;
 
@@ -144,10 +157,12 @@ SELECT x.a AS a FROM x AS x WHERE x.b IN (SELECT x.b AS b FROM y AS x);
 SELECT a FROM x AS i WHERE b IN (SELECT b FROM y AS j WHERE j.b IN (SELECT c FROM y AS k WHERE k.b = j.b));
 SELECT i.a AS a FROM x AS i WHERE i.b IN (SELECT j.b AS b FROM y AS j WHERE j.b IN (SELECT k.c AS c FROM y AS k WHERE k.b = j.b));
 
+# execute: false
 # dialect: bigquery
 SELECT aa FROM x, UNNEST(a) AS aa;
 SELECT aa AS aa FROM x AS x, UNNEST(x.a) AS aa;
 
+# execute: false
 SELECT aa FROM x, UNNEST(a) AS t(aa);
 SELECT t.aa AS aa FROM x AS x, UNNEST(x.a) AS t(aa);
 
@@ -205,15 +220,19 @@ WITH z AS ((SELECT x.b AS b FROM x AS x UNION ALL SELECT y.b AS b FROM y AS y) O
 --------------------------------------
 -- Except and Replace
 --------------------------------------
+# execute: false
 SELECT * REPLACE(a AS d) FROM x;
 SELECT x.a AS d, x.b AS b FROM x AS x;
 
+# execute: false
 SELECT * EXCEPT(b) REPLACE(a AS d) FROM x;
 SELECT x.a AS d FROM x AS x;
 
+# execute: false
 SELECT x.* EXCEPT(a), y.* FROM x, y;
 SELECT x.b AS b, y.b AS b, y.c AS c FROM x AS x, y AS y;
 
+# execute: false
 SELECT * EXCEPT(a) FROM x;
 SELECT x.b AS b FROM x AS x;
 
-- 
cgit v1.2.3

