Files
impala/testdata/workloads/functional-query/queries/QueryTest/alias.test
Yongzhi Chen 0cd690dcbc IMPALA-9025: Handle AnalysisException caused by expr_rewrites
properly

When the optimizer rewrites conjunct exprs with constant values,
a new expr may cause AnalysisException. In this case,
the conjuncts should use the original expr, not the intermediate
expr produced by propagateConstants. Fixed optimizeConjuncts
to handle this scenario properly.

Tests:
Add unit test for alias.
Ran exhaustive tests.

Change-Id: Ic57bf3f4cdabfe9c5bb304d735bfbf1c0ca7a274
Reviewed-on: http://gerrit.cloudera.org:8080/14403
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2019-10-16 02:04:12 +00:00

97 lines
1.4 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
====
---- QUERY
# literal alias
# IMPALA-9025: When constant propagation optimization fails, the query fails
# with "ERROR: IllegalStateException: null"
select * from (select t.* from alltypestiny t
inner join (select 10 bigint_col) d where
t.int_col < d.bigint_col ) q
where int_col <> bigint_col and int_col = 10
====