diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-12-19 11:01:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-12-19 11:01:36 +0000 |
commit | 948a422be120c069e48c63a8770fec7204307897 (patch) | |
tree | 80bc02d5e6cd3527409386aa1d706272bea54e6c /tests/fixtures/optimizer/eliminate_ctes.sql | |
parent | Adding upstream version 20.1.0. (diff) | |
download | sqlglot-948a422be120c069e48c63a8770fec7204307897.tar.xz sqlglot-948a422be120c069e48c63a8770fec7204307897.zip |
Adding upstream version 20.3.0.upstream/20.3.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/fixtures/optimizer/eliminate_ctes.sql')
-rw-r--r-- | tests/fixtures/optimizer/eliminate_ctes.sql | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/fixtures/optimizer/eliminate_ctes.sql b/tests/fixtures/optimizer/eliminate_ctes.sql index 11e5e4f..f1f78f4 100644 --- a/tests/fixtures/optimizer/eliminate_ctes.sql +++ b/tests/fixtures/optimizer/eliminate_ctes.sql @@ -46,3 +46,71 @@ FROM x; SELECT a FROM x; + +# title: CTE reference in subquery where alias matches outer table name +WITH q AS ( + SELECT + a + FROM y +) +SELECT + a +FROM x AS q +WHERE + a IN ( + SELECT + a + FROM q + ); +WITH q AS ( + SELECT + a + FROM y +) +SELECT + a +FROM x AS q +WHERE + a IN ( + SELECT + a + FROM q + ); + +# title: CTE reference in subquery where alias matches outer table name and outer alias is also CTE +WITH q AS ( + SELECT + a + FROM y +), q2 AS ( + SELECT + a + FROM y +) +SELECT + a +FROM q2 AS q +WHERE + a IN ( + SELECT + a + FROM q + ); +WITH q AS ( + SELECT + a + FROM y +), q2 AS ( + SELECT + a + FROM y +) +SELECT + a +FROM q2 AS q +WHERE + a IN ( + SELECT + a + FROM q + );
\ No newline at end of file |