1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
# name: test/sql/binder/alias_qualification_where.test
# description: Test alias.name resolution in WHERE clause
# group: [binder]
# basic filtering using projection alias in WHERE
query I
SELECT a AS x FROM (VALUES (1),(2),(3)) t(a)
WHERE alias.x > 1
ORDER BY a;
----
2
3
# alias chaining shouldn't be necessary in WHERE, but referencing another alias should work
query II
SELECT a + 1 AS x, alias.x * 2 AS y FROM (VALUES (1),(2)) t(a)
WHERE alias.y >= 6
ORDER BY a;
----
3 6
# quoted alias in WHERE
query I
SELECT a AS "MiXeD" FROM (VALUES (0),(1)) t(a)
WHERE alias."MiXeD" = 1;
----
1
# ensure a table actually named `alias` still works and does not conflict with alias references
statement ok
CREATE TABLE alias (v INT);
statement ok
INSERT INTO alias VALUES (10), (20);
# The table-qualified column reference should still be prioritized over alias references
query I
SELECT v AS x FROM alias
WHERE alias.v > 10
ORDER BY v;
----
20
|