Files
impala/testdata/workloads/functional-query/queries/QueryTest/views-compatibility.test
Alex Behm 52c9d26d16 IMPALA-475: Impala should avoid the use of c_# style autogenerated column aliases unless necessary.
Change-Id: I959e35bcee1698ebc35534dc4f390c5c2c7dc919
Reviewed-on: http://gerrit.ent.cloudera.com:8080/141
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: Alex Behm <alex.behm@cloudera.com>
2014-01-08 10:52:03 -08:00

185 lines
5.3 KiB
Plaintext

====
---- CREATE_VIEW
# Simple view without removing/renaming any columns.
create view test as select * from functional.alltypes
---- CREATE_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
---- QUERY_HIVE_VIEW_RESULTS
IMPALA=SUCCESS
---- QUERY_IMPALA_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
====
---- CREATE_VIEW
# Simple view some columns renamed.
create view test (abc, xyz) as
select string_col, timestamp_col from functional.alltypes
---- CREATE_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
---- QUERY_HIVE_VIEW_RESULTS
IMPALA=SUCCESS
---- QUERY_IMPALA_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
====
---- CREATE_VIEW
# View with aggregates and group by.
create view test (c, a, g) as
select count(string_col) as x, avg(bigint_col) as y, int_col
from functional.alltypes group by int_col
---- CREATE_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
---- QUERY_HIVE_VIEW_RESULTS
IMPALA=SUCCESS
---- QUERY_IMPALA_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
====
---- CREATE_VIEW
# Test that auto-generated column names are fully compatible
# (non-SlotRef exprs use auto-generated column names)
create view test as
select int_col % 3, trim(string_col), float_col * 10
from functional.alltypes
---- CREATE_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
---- QUERY_HIVE_VIEW_RESULTS
IMPALA=SUCCESS
---- QUERY_IMPALA_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
====
---- CREATE_VIEW
# Test that auto-generated column names are fully compatible
# (non-SlotRef exprs use auto-generated column names)
create view test (a, b, c) as
select int_col % 3, trim(string_col), float_col * 10
from functional.alltypes
---- CREATE_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
---- QUERY_HIVE_VIEW_RESULTS
IMPALA=SUCCESS
---- QUERY_IMPALA_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
====
---- CREATE_VIEW
# Test that exotic column names are quoted in
# Impala's view to make them parseable by Hive.
# Hive cannot parse the unquoted identifiers starting with "_",
# so the view creation should fail.
create view test as
select _c0, _c1, _c2 from
(select int_col % 3 AS _c0, trim(string_col) AS _c1, float_col * 10 AS _c2
from functional.alltypes) t
---- CREATE_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=FAILURE
---- QUERY_IMPALA_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
====
---- CREATE_VIEW
# Test that Impala adds quotes to table aliases if necessary
# and that Impala omits "AS" for table aliases to make
# the view parseable by Hive. Hive cannot parse "AS" before table aliases,
# so Hive's view creation should fail but it should be able to parse
# Impala's view.
create view test as
select int_col, string_col, float_col from
(select int_col, string_col, float_col
from functional.alltypes) as t
---- CREATE_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=FAILURE
---- QUERY_IMPALA_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
====
---- CREATE_VIEW
# Same test as above, except without the "AS" to make the view creation
# in Hive succeed. Both Impala and Hive should be able to parse the view.
create view test as
select int_col, string_col, float_col from
(select int_col, string_col, float_col
from functional.alltypes) t
---- CREATE_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
---- QUERY_HIVE_VIEW_RESULTS
IMPALA=SUCCESS
---- QUERY_IMPALA_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
====
---- CREATE_VIEW
# Test a complex query with subqueries, joins, aggregates, group by,
# order by and limit. The view is not parsable by Hive because Hive
# requires explicit aliases for columns referenced in the oder by clause.
create view test (a, b, c) as
select count(t1.int_col), avg(t2.float_col), t1.string_col from
(select id, int_col, string_col from functional.alltypesagg where id < 10) t1
inner join
(select id, float_col, string_col from functional.alltypes where id < 5) t2
on t1.id = t2.id
where t1.int_col % 2 = 0 and t2.float_col is not null
group by t1.string_col having count(t2.float_col) > 2
order by t1.string_col limit 100
---- CREATE_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=FAILURE
---- QUERY_IMPALA_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=FAILURE
====
---- CREATE_VIEW
# Test a complex query with an explicit alias for the order-by columns.
# This time both Hive and Impala can parse the view.
create view test (a, b, c) as
select count(t1.int_col), avg(t2.float_col), t1.string_col as scol from
(select id, int_col, string_col from functional.alltypesagg where id < 10) t1
inner join
(select id, float_col, string_col from functional.alltypes where id < 5) t2
on t1.id = t2.id
where t1.int_col % 2 = 0 and t2.float_col is not null
group by t1.string_col having count(t2.float_col) > 2
order by scol limit 100
---- CREATE_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
---- QUERY_HIVE_VIEW_RESULTS
IMPALA=SUCCESS
---- QUERY_IMPALA_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
====
---- CREATE_VIEW
# Test that identifiers requiring quotes have quotes in
# their view definition and are parseable by both Hive and Impala.
create view test (abc, xyz) as
select string_col as `^^^`, int_col as `???` from functional.alltypes
---- CREATE_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
---- QUERY_HIVE_VIEW_RESULTS
IMPALA=SUCCESS
---- QUERY_IMPALA_VIEW_RESULTS
IMPALA=SUCCESS
HIVE=SUCCESS
====
---- CREATE_VIEW
# A view that uses a Hive-specfic SQL construct (SORT BY)
# is expected to work only in Hive (and fail gracefully in Impala).
create view test as select int_col from functional.alltypes sort by int_col
---- CREATE_VIEW_RESULTS
IMPALA=FAILURE
HIVE=SUCCESS
---- QUERY_HIVE_VIEW_RESULTS
IMPALA=FAILURE
====