Files
impala/testdata/workloads/functional-query/queries/QueryTest/alias.test
Zoltan Borok-Nagy 545e60f832 IMPALA-5191: Standardize column alias behavior
We should not perform alias substitution in the
subexpressions of GROUP BY, HAVING, and ORDER BY
to be more standard conformant.

=== Allowed ===
SELECT int_col / 2 AS x
FROM functional.alltypes
GROUP BY x;

SELECT int_col / 2 AS x
FROM functional.alltypes
ORDER BY x;

SELECT NOT bool_col AS nb
FROM functional.alltypes
GROUP BY nb
HAVING nb;

=== Not allowed ===
SELECT int_col / 2 AS x
FROM functional.alltypes
GROUP BY x / 2;

SELECT int_col / 2 AS x
FROM functional.alltypes
ORDER BY -x;

SELECT int_col / 2 AS x
FROM functional.alltypes
GROUP BY x
HAVING x > 3;

Some extra checks were added to AnalyzeExprsTest.java.

I had to update other tests to make them pass
since the new behavior is more restrictive.

I added alias.test to the end-to-end tests.

Cherry-picks: not for 2.x.

Change-Id: I0f82483b486acf6953876cfa672b0d034f3709a8
Reviewed-on: http://gerrit.cloudera.org:8080/8801
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: Impala Public Jenkins
2018-01-24 22:47:18 +00:00

88 lines
1.1 KiB
Plaintext

====
---- QUERY
# GROUP BY alias
select int_col / 2 as x from alltypes group by x
---- RESULTS
1.5
3.5
4.5
3
1
0.5
4
0
2
2.5
---- TYPES
double
====
---- QUERY
# GROUP BY alias ORDER BY alias
select int_col / 2 as x from alltypes group by x order by x
---- RESULTS
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
---- TYPES
double
====
---- QUERY
# HAVING with bool typed alias
select int_col / 2 as x, not bool_col as nb
from alltypes group by x, nb having nb
---- RESULTS
0.5,true
3.5,true
1.5,true
4.5,true
2.5,true
---- TYPES
double,boolean
====
---- QUERY
# count(*) alias ORDER BY
select count(*) a from alltypes order by a
---- RESULTS
7300
---- TYPES
bigint
====
---- QUERY
# count(*) > 10 alias ORDER BY
select count(*) > 10 a from alltypes order by a
---- RESULTS
true
---- TYPES
boolean
====
---- QUERY
# count(*) > 10 alias HAVING
select count(*) > 10 a from alltypes having a
---- RESULTS
true
---- TYPES
boolean
====
---- QUERY
# sum(id) over(order by id) alias ORDER BY
select sum(id) over(order by id) a from alltypestiny order by a
---- RESULTS
0
1
3
6
10
15
21
28
---- TYPES
bigint
====