should be it
This commit is contained in:
75
external/duckdb/test/sql/binder/test_alias.test
vendored
Normal file
75
external/duckdb/test/sql/binder/test_alias.test
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
# name: test/sql/binder/test_alias.test
|
||||
# description: Test that aliases work properly in renaming columns
|
||||
# group: [binder]
|
||||
|
||||
statement ok
|
||||
SET default_null_order='nulls_first';
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE integers(i INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO integers VALUES (1), (2), (3), (NULL)
|
||||
|
||||
query IR
|
||||
SELECT i % 2 AS p, SUM(i) AS sum_i FROM integers GROUP BY p ORDER BY 1
|
||||
----
|
||||
NULL NULL
|
||||
0 2.000000
|
||||
1 4.000000
|
||||
|
||||
query TT
|
||||
SELECT alias(i % 2) AS p, alias(SUM(i)) AS sum_i FROM integers GROUP BY p ORDER BY 1
|
||||
----
|
||||
p sum_i
|
||||
|
||||
query II
|
||||
SELECT i + 1 + 1 + 1 AS k, abs(i) AS l FROM integers WHERE i=1 ORDER BY 1
|
||||
----
|
||||
4 1
|
||||
|
||||
query TT
|
||||
SELECT alias(i + 1 + 1 + 1) AS k, alias(abs(i)) AS l FROM integers WHERE i=1 ORDER BY 1
|
||||
----
|
||||
k l
|
||||
|
||||
query TTTT
|
||||
SELECT alias(i) AS k, alias(i IN (1)) AS l, alias(i >= 10) AS m, alias(1=0) AS n FROM integers WHERE i=1 ORDER BY 1
|
||||
----
|
||||
k l m n
|
||||
|
||||
query TT
|
||||
SELECT alias(CASE WHEN i=1 THEN 19 ELSE 0 END) AS k, alias(i::VARCHAR) AS l FROM integers WHERE i=1 ORDER BY 1
|
||||
----
|
||||
k l
|
||||
|
||||
statement ok
|
||||
CREATE TABLE test (a INTEGER, b INTEGER)
|
||||
|
||||
statement ok
|
||||
INSERT INTO test VALUES (42, 10), (43, 100);
|
||||
|
||||
# check column names for simple projections and aliases
|
||||
query IIII
|
||||
SELECT a, b, a * 2 AS c, b * (a * 2) AS d FROM test ORDER BY a
|
||||
----
|
||||
42 10 84 840
|
||||
43 100 86 8600
|
||||
|
||||
query TTTT
|
||||
SELECT alias(a), alias(b), alias(a * 2) AS c, alias(b * (a * 2)) AS d FROM test ORDER BY a
|
||||
----
|
||||
a b c d
|
||||
a b c d
|
||||
|
||||
|
||||
# test nested alias in where clause
|
||||
query IIII
|
||||
select i as b, b as c, c as d, d as e from integers where e = 3;
|
||||
----
|
||||
3 3 3 3
|
||||
|
||||
|
||||
Reference in New Issue
Block a user