mirror of
https://github.com/apache/impala.git
synced 2026-02-03 09:00:39 -05:00
IMPALA-9496: Allow struct type in the select list for Parquet tables
This patch is to extend the support of Struct columns in the select
list to Parquet files as well.
There are some limitation with this patch:
- Dictionary filtering could work when we have conjuncts on a member
of a struct, however, if this struct is given in the select list
then the dictionary filtering is disabled. The reason is that in
this case there would be a mismatch between the slot/tuple IDs in
the conjunct between the ones in the select list due to expr
substitution logic when a struct is in the select list. Solving
this puzzle would be a nice future performance enhancement. See
IMPALA-11361.
- When structs are read in a batched manner it delegates the actual
reading of the data to the column readers of its children, however,
would use the simple ReadValue() on these readers instead of the
batched version. The reason is that calling the batched reader in
the member column readers would in fact read in batches, but it
won't handle the case when the parent struct is NULL and would set
only itself to NULL but not the parent struct. This might also be a
future performance enhancement. See IMPALA-11363.
- If there is a struct in the select list then late materialization
is turned off. The reason is that LM expects the column readers to
be used through the batched reading interface, however, as said in
the above bulletpoint currently struct column readers use the
non-batched reading interface of its children. As a result after
reading the column readers are not in a state as SkipRows() of LM
expects and then results in a query failure because it's not able
to skip the rows for non-filter readers.
Once IMPALA-11363 is implemented and the struct will also use the
ReadValueBatch() interface of its children then late
materialization could be turned on even if structs are in the
select list. See IMPALA-11364.
Testing:
- There were a lot of tests already to exercise this functionality
but they were only run on ORC table. I changed these to cover
Parquet tables too.
Change-Id: I3e8b4cbc2c4d1dd5fbefb7c87dad8d4e6ac2f452
Reviewed-on: http://gerrit.cloudera.org:8080/18596
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
committed by
Impala Public Jenkins
parent
da14fdcf35
commit
5d021ce5a7
@@ -2,7 +2,7 @@
|
||||
---- QUERY
|
||||
# Select a struct that contains multiple structs.
|
||||
select id, outer_struct
|
||||
from functional_orc_def.complextypes_nested_structs;
|
||||
from complextypes_nested_structs;
|
||||
---- RESULTS
|
||||
1,'{"str":"somestr1","inner_struct1":{"str":"somestr2","de":12345.12},"inner_struct2":{"i":333222111,"str":"somestr3"},"inner_struct3":{"s":{"i":112288,"s":null}}}'
|
||||
2,'{"str":"str","inner_struct1":null,"inner_struct2":{"i":100,"str":"str3"},"inner_struct3":{"s":{"i":321,"s":"dfgs"}}}'
|
||||
@@ -15,7 +15,7 @@ INT,STRING
|
||||
---- QUERY
|
||||
# Select a struct that contains multiple structs using a filter on a non-struct field.
|
||||
select id, outer_struct
|
||||
from functional_orc_def.complextypes_nested_structs
|
||||
from complextypes_nested_structs
|
||||
where id > 2;
|
||||
---- RESULTS
|
||||
3,'NULL'
|
||||
@@ -27,7 +27,7 @@ INT,STRING
|
||||
---- QUERY
|
||||
# Select a struct that contains multiple structs using a filter on a struct field.
|
||||
select id, outer_struct
|
||||
from functional_orc_def.complextypes_nested_structs
|
||||
from complextypes_nested_structs
|
||||
where length(outer_struct.str) > 3;
|
||||
---- RESULTS
|
||||
1,'{"str":"somestr1","inner_struct1":{"str":"somestr2","de":12345.12},"inner_struct2":{"i":333222111,"str":"somestr3"},"inner_struct3":{"s":{"i":112288,"s":null}}}'
|
||||
@@ -37,7 +37,7 @@ INT,STRING
|
||||
---- QUERY
|
||||
# Select a nested struct with an order by.
|
||||
select id, outer_struct
|
||||
from functional_orc_def.complextypes_nested_structs
|
||||
from complextypes_nested_structs
|
||||
order by id;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
1,'{"str":"somestr1","inner_struct1":{"str":"somestr2","de":12345.12},"inner_struct2":{"i":333222111,"str":"somestr3"},"inner_struct3":{"s":{"i":112288,"s":null}}}'
|
||||
@@ -51,7 +51,7 @@ INT,STRING
|
||||
---- QUERY
|
||||
# Select a nested struct with an order by.
|
||||
select id, outer_struct
|
||||
from functional_orc_def.complextypes_nested_structs
|
||||
from complextypes_nested_structs
|
||||
order by id desc;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
5,'{"str":null,"inner_struct1":null,"inner_struct2":null,"inner_struct3":null}'
|
||||
@@ -65,7 +65,7 @@ INT,STRING
|
||||
---- QUERY
|
||||
# Select the same nested struct multiple times in one query.
|
||||
select id, outer_struct, outer_struct
|
||||
from functional_orc_def.complextypes_nested_structs;
|
||||
from complextypes_nested_structs;
|
||||
---- RESULTS
|
||||
1,'{"str":"somestr1","inner_struct1":{"str":"somestr2","de":12345.12},"inner_struct2":{"i":333222111,"str":"somestr3"},"inner_struct3":{"s":{"i":112288,"s":null}}}','{"str":"somestr1","inner_struct1":{"str":"somestr2","de":12345.12},"inner_struct2":{"i":333222111,"str":"somestr3"},"inner_struct3":{"s":{"i":112288,"s":null}}}'
|
||||
2,'{"str":"str","inner_struct1":null,"inner_struct2":{"i":100,"str":"str3"},"inner_struct3":{"s":{"i":321,"s":"dfgs"}}}','{"str":"str","inner_struct1":null,"inner_struct2":{"i":100,"str":"str3"},"inner_struct3":{"s":{"i":321,"s":"dfgs"}}}'
|
||||
@@ -78,7 +78,7 @@ INT,STRING,STRING
|
||||
---- QUERY
|
||||
# Select the same nested struct multiple times in one query and order the results.
|
||||
select id, outer_struct, outer_struct
|
||||
from functional_orc_def.complextypes_nested_structs
|
||||
from complextypes_nested_structs
|
||||
order by id desc;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
5,'{"str":null,"inner_struct1":null,"inner_struct2":null,"inner_struct3":null}','{"str":null,"inner_struct1":null,"inner_struct2":null,"inner_struct3":null}'
|
||||
@@ -93,7 +93,7 @@ INT,STRING,STRING
|
||||
# Similar to the above query but here the 'id' field is not in the select list but still
|
||||
# used in the order by.
|
||||
select outer_struct, outer_struct
|
||||
from functional_orc_def.complextypes_nested_structs
|
||||
from complextypes_nested_structs
|
||||
order by id desc;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
'{"str":null,"inner_struct1":null,"inner_struct2":null,"inner_struct3":null}','{"str":null,"inner_struct1":null,"inner_struct2":null,"inner_struct3":null}'
|
||||
@@ -105,9 +105,18 @@ order by id desc;
|
||||
STRING,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Select an inner struct where the outer struct is null.
|
||||
select outer_struct.inner_struct1 from complextypes_nested_structs
|
||||
where id = 3;
|
||||
---- RESULTS
|
||||
'NULL'
|
||||
---- TYPES
|
||||
STRING
|
||||
====
|
||||
---- QUERY
|
||||
# WITH clause creates an inline view containing a nested struct.
|
||||
with sub as (
|
||||
select id, outer_struct from functional_orc_def.complextypes_nested_structs)
|
||||
select id, outer_struct from complextypes_nested_structs)
|
||||
select sub.id, sub.outer_struct from sub;
|
||||
---- RESULTS
|
||||
1,'{"str":"somestr1","inner_struct1":{"str":"somestr2","de":12345.12},"inner_struct2":{"i":333222111,"str":"somestr3"},"inner_struct3":{"s":{"i":112288,"s":null}}}'
|
||||
@@ -122,7 +131,7 @@ INT,STRING
|
||||
# WITH clause creates an inline view containing a nested struct and we query a nested
|
||||
# field.
|
||||
with sub as (
|
||||
select id, outer_struct from functional_orc_def.complextypes_nested_structs)
|
||||
select id, outer_struct from complextypes_nested_structs)
|
||||
select sub.id, sub.outer_struct.inner_struct2 from sub;
|
||||
---- RESULTS
|
||||
1,'{"i":333222111,"str":"somestr3"}'
|
||||
@@ -137,7 +146,7 @@ INT,STRING
|
||||
# WITH clause creates an inline view containing a nested struct and we query a doubly
|
||||
# nested field.
|
||||
with sub as (
|
||||
select id, outer_struct from functional_orc_def.complextypes_nested_structs)
|
||||
select id, outer_struct from complextypes_nested_structs)
|
||||
select sub.id, sub.outer_struct.inner_struct2.i from sub;
|
||||
---- RESULTS
|
||||
1,333222111
|
||||
@@ -153,7 +162,7 @@ INT,INT
|
||||
# that is a struct itself; query both in the main select statement.
|
||||
with sub as (
|
||||
select id, outer_struct, outer_struct.inner_struct3 inner3
|
||||
from functional_orc_def.complextypes_nested_structs)
|
||||
from complextypes_nested_structs)
|
||||
select id, outer_struct, inner3 from sub;
|
||||
---- RESULTS
|
||||
1,'{"str":"somestr1","inner_struct1":{"str":"somestr2","de":12345.12},"inner_struct2":{"i":333222111,"str":"somestr3"},"inner_struct3":{"s":{"i":112288,"s":null}}}','{"s":{"i":112288,"s":null}}'
|
||||
@@ -170,7 +179,7 @@ INT,STRING,STRING
|
||||
# 'outer_struct' as well as 'inner3' in the main select statement.
|
||||
with sub as (
|
||||
select id, outer_struct, outer_struct.inner_struct3 inner3
|
||||
from functional_orc_def.complextypes_nested_structs)
|
||||
from complextypes_nested_structs)
|
||||
select id, outer_struct.inner_struct2, inner3 from sub;
|
||||
---- RESULTS
|
||||
1,'{"i":333222111,"str":"somestr3"}','{"s":{"i":112288,"s":null}}'
|
||||
@@ -187,7 +196,7 @@ INT,STRING,STRING
|
||||
# 'outer_struct' as well as a member of 'inner3' in the main select statement.
|
||||
with sub as (
|
||||
select id, outer_struct, outer_struct.inner_struct3 inner3
|
||||
from functional_orc_def.complextypes_nested_structs)
|
||||
from complextypes_nested_structs)
|
||||
select id, outer_struct.inner_struct2, inner3.s from sub;
|
||||
---- RESULTS
|
||||
1,'{"i":333222111,"str":"somestr3"}','{"i":112288,"s":null}'
|
||||
@@ -201,7 +210,7 @@ INT,STRING,STRING
|
||||
---- QUERY
|
||||
# WITH clause creates an inline view containing a nested struct; we order by id.
|
||||
with sub as (
|
||||
select id, outer_struct from functional_orc_def.complextypes_nested_structs)
|
||||
select id, outer_struct from complextypes_nested_structs)
|
||||
select sub.id, sub.outer_struct.inner_struct2 from sub order by sub.id desc;
|
||||
---- RESULTS
|
||||
5,'NULL'
|
||||
@@ -216,7 +225,7 @@ INT,STRING
|
||||
# WITH clause creates an inline view containing a nested struct; we order by a nested
|
||||
# field.
|
||||
with sub as (
|
||||
select id, outer_struct from functional_orc_def.complextypes_nested_structs)
|
||||
select id, outer_struct from complextypes_nested_structs)
|
||||
select sub.id, sub.outer_struct.inner_struct2 from sub
|
||||
order by sub.outer_struct.inner_struct2.i, sub.id;
|
||||
---- RESULTS
|
||||
@@ -232,7 +241,7 @@ INT,STRING
|
||||
# WITH clause creates an inline view containing a nested struct; we order by a nested
|
||||
# field that is not present in the select list.
|
||||
with sub as (
|
||||
select id, outer_struct from functional_orc_def.complextypes_nested_structs)
|
||||
select id, outer_struct from complextypes_nested_structs)
|
||||
select sub.id, sub.outer_struct.inner_struct1 from sub
|
||||
order by sub.outer_struct.inner_struct2.i, sub.id;
|
||||
---- RESULTS
|
||||
@@ -248,7 +257,7 @@ INT,STRING
|
||||
# WITH clause creates an inline view containing a nested struct; filter by a struct field
|
||||
# from the inline view.
|
||||
with sub as (
|
||||
select id, outer_struct from functional_orc_def.complextypes_nested_structs)
|
||||
select id, outer_struct from complextypes_nested_structs)
|
||||
select sub.id, sub.outer_struct.str
|
||||
from sub
|
||||
where length(sub.outer_struct.str) < 4;
|
||||
@@ -263,7 +272,7 @@ INT,STRING
|
||||
# filter by one of its fields.
|
||||
with sub as (
|
||||
select id, outer_struct.inner_struct1 s1, outer_struct.inner_struct2 s2
|
||||
from functional_orc_def.complextypes_nested_structs)
|
||||
from complextypes_nested_structs)
|
||||
select sub.id, s2
|
||||
from sub
|
||||
where length(s2.str) < 8;
|
||||
@@ -277,7 +286,7 @@ INT,STRING
|
||||
# WITH clause creates an inline view containing a nested struct; filter by a struct field
|
||||
# from the inline view but do not select anything from it.
|
||||
with sub as (
|
||||
select id, outer_struct from functional_orc_def.complextypes_nested_structs)
|
||||
select id, outer_struct from complextypes_nested_structs)
|
||||
select 1
|
||||
from sub
|
||||
where length(sub.outer_struct.str) < 4;
|
||||
@@ -292,7 +301,7 @@ TINYINT
|
||||
# the inline view and ordering by a non-complex item from the view.
|
||||
with sub as (
|
||||
select id, outer_struct
|
||||
from functional_orc_def.complextypes_nested_structs
|
||||
from complextypes_nested_structs
|
||||
where length(outer_struct.str) > 3)
|
||||
select sub.id, sub.outer_struct from sub order by sub.id desc;
|
||||
---- RESULTS
|
||||
@@ -303,7 +312,7 @@ INT,STRING
|
||||
---- QUERY
|
||||
# Two-level inline view, querying a struct filed.
|
||||
with sub as (
|
||||
select id, outer_struct from functional_orc_def.complextypes_nested_structs)
|
||||
select id, outer_struct from complextypes_nested_structs)
|
||||
select id, s from (select id, outer_struct.inner_struct1 as s from sub) v
|
||||
order by id;
|
||||
---- RESULTS
|
||||
@@ -318,7 +327,7 @@ INT,STRING
|
||||
---- QUERY
|
||||
# Two-level inline view, querying the top level struct.
|
||||
with sub as (
|
||||
select id, outer_struct from functional_orc_def.complextypes_nested_structs)
|
||||
select id, outer_struct from complextypes_nested_structs)
|
||||
select id, s from (select id, outer_struct as s from sub) v
|
||||
order by id;
|
||||
---- RESULTS
|
||||
@@ -335,7 +344,7 @@ INT,STRING
|
||||
# when the struct fields in the predicate are itemTupleDescriptors within the struct(s),
|
||||
# not in the main tuple.
|
||||
select id, outer_struct
|
||||
from functional_orc_def.complextypes_nested_structs
|
||||
from complextypes_nested_structs
|
||||
where outer_struct.inner_struct2.i > length(outer_struct.str)
|
||||
---- RESULTS
|
||||
1,'{"str":"somestr1","inner_struct1":{"str":"somestr2","de":12345.12},"inner_struct2":{"i":333222111,"str":"somestr3"},"inner_struct3":{"s":{"i":112288,"s":null}}}'
|
||||
@@ -349,7 +358,7 @@ INT,STRING
|
||||
# enclosing struct is embedded in another one, but the top level struct is not present in
|
||||
# the query.
|
||||
select id, outer_struct.inner_struct2.i, outer_struct.inner_struct2
|
||||
from functional_orc_def.complextypes_nested_structs;
|
||||
from complextypes_nested_structs;
|
||||
---- RESULTS
|
||||
1,333222111,'{"i":333222111,"str":"somestr3"}'
|
||||
2,100,'{"i":100,"str":"str3"}'
|
||||
@@ -363,8 +372,8 @@ INT,INT,STRING
|
||||
# An inner join where struct fields are in the join condition and their parent struct is
|
||||
# in the select list.
|
||||
select a.outer_struct, b.small_struct
|
||||
from functional_orc_def.complextypes_nested_structs a
|
||||
inner join functional_orc_def.complextypes_structs b
|
||||
from complextypes_nested_structs a
|
||||
inner join complextypes_structs b
|
||||
on b.small_struct.i = a.outer_struct.inner_struct2.i + 19091;
|
||||
---- RESULTS
|
||||
'{"str":"str","inner_struct1":null,"inner_struct2":{"i":100,"str":"str3"},"inner_struct3":{"s":{"i":321,"s":"dfgs"}}}','{"i":19191,"s":"small_struct_str"}'
|
||||
@@ -375,8 +384,8 @@ STRING,STRING
|
||||
# An outer join where struct fields are in the join condition and their parent struct is
|
||||
# in the select list.
|
||||
select a.outer_struct, b.small_struct
|
||||
from functional_orc_def.complextypes_nested_structs a
|
||||
full outer join functional_orc_def.complextypes_structs b
|
||||
from complextypes_nested_structs a
|
||||
full outer join complextypes_structs b
|
||||
on b.small_struct.i = a.outer_struct.inner_struct2.i + 19091;
|
||||
---- RESULTS
|
||||
'{"str":"somestr1","inner_struct1":{"str":"somestr2","de":12345.12},"inner_struct2":{"i":333222111,"str":"somestr3"},"inner_struct3":{"s":{"i":112288,"s":null}}}','NULL'
|
||||
@@ -394,7 +403,7 @@ STRING,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Checks that "SELECT nested_struct.* ..." omits the nested structs from the output.
|
||||
select id, outer_struct.* from functional_orc_def.complextypes_nested_structs;
|
||||
select id, outer_struct.* from complextypes_nested_structs;
|
||||
---- RESULTS
|
||||
1,'somestr1'
|
||||
2,'str'
|
||||
@@ -406,8 +415,8 @@ INT,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# IMPALA-10839: Display nulls at the correct level.
|
||||
select id, outer_struct.inner_struct3 from
|
||||
functional_orc_def.complextypes_nested_structs;
|
||||
select id, outer_struct.inner_struct3
|
||||
from complextypes_nested_structs;
|
||||
---- RESULTS
|
||||
1,'{"s":{"i":112288,"s":null}}'
|
||||
2,'{"s":{"i":321,"s":"dfgs"}}'
|
||||
@@ -419,8 +428,8 @@ INT,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# IMPALA-10839: Display nulls at the correct level.
|
||||
select id, outer_struct.inner_struct3.s from
|
||||
functional_orc_def.complextypes_nested_structs;
|
||||
select id, outer_struct.inner_struct3.s
|
||||
from complextypes_nested_structs;
|
||||
---- RESULTS
|
||||
1,'{"i":112288,"s":null}'
|
||||
2,'{"i":321,"s":"dfgs"}'
|
||||
@@ -434,10 +443,10 @@ INT,STRING
|
||||
# Subquery that returns a complex type is not supported.
|
||||
# IMPALA-9500
|
||||
select outer_struct
|
||||
from functional_orc_def.complextypes_nested_structs
|
||||
from complextypes_nested_structs
|
||||
where outer_struct in
|
||||
(select outer_struct from functional_orc_def.complextypes_nested_structs);
|
||||
(select outer_struct from functional_parquet.complextypes_nested_structs);
|
||||
---- CATCH
|
||||
AnalysisException: A subquery can't return complex types. (SELECT outer_struct FROM functional_orc_def.complex
|
||||
AnalysisException: A subquery can't return complex types. (SELECT outer_struct FROM functional_parquet.complex
|
||||
types_nested_structs)
|
||||
====
|
||||
|
||||
@@ -48,15 +48,16 @@ int,int,int,int
|
||||
====
|
||||
---- QUERY
|
||||
# Incorrect field resolutions with THREE_LEVEL and POSITION
|
||||
# because the data file uses the 2-level encoding.
|
||||
# because the data file uses the 2-level encoding. We get an error due to unsuccessfully
|
||||
# resolving the struct part. The full error message is the following:
|
||||
# File '<host_specific_url>/ambig_legacy/AmbiguousList_Legacy.parquet' has an incompatible
|
||||
# Parquet schema for column '<DB_name>.ambig_legacy.ambigarray.item.s2'. Column type:
|
||||
# struct, Parquet schema: optional int32 f21 [i:0 d:2 r:1]
|
||||
set parquet_fallback_schema_resolution=position;
|
||||
set parquet_array_resolution=three_level;
|
||||
select f11, f12, s2.f21, s2.f22 from ambig_legacy.ambigarray;
|
||||
---- RESULTS
|
||||
22,NULL,NULL,NULL
|
||||
220,NULL,NULL,NULL
|
||||
---- TYPES
|
||||
int,int,int,int
|
||||
---- CATCH
|
||||
has an incompatible Parquet schema for column
|
||||
====
|
||||
---- QUERY
|
||||
# All fields are interpreted as missing with THREE_LEVEL and NAME.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
====
|
||||
---- QUERY
|
||||
# Select a simple struct with one bool member.
|
||||
select id, tiny_struct from functional_orc_def.complextypes_structs;
|
||||
select id, tiny_struct from complextypes_structs;
|
||||
---- RESULTS
|
||||
1,'{"b":true}'
|
||||
2,'{"b":false}'
|
||||
@@ -14,7 +14,7 @@ INT,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Similar query as above but with an order by.
|
||||
select id, tiny_struct from functional_orc_def.complextypes_structs order by id;
|
||||
select id, tiny_struct from complextypes_structs order by id;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
1,'{"b":true}'
|
||||
2,'{"b":false}'
|
||||
@@ -29,7 +29,7 @@ INT,STRING
|
||||
# Ordering by a member of the struct.
|
||||
# Forced to use a SORT node instead of a TOPN.
|
||||
set disable_outermost_topn = 1;
|
||||
select id, alltypes from functional_orc_def.complextypes_structs
|
||||
select id, alltypes from complextypes_structs
|
||||
order by alltypes.ti;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
4,'{"ti":90,"si":30482,"i":1664336,"bi":23567459873,"b":true,"f":0.5600000023841858,"do":NaN,"da":"2000-12-31","ts":"2024-01-01 00:00:00.123400000","s1":"random string","s2":"","c1":"c","c2":"d ","vc":"addsdrr","de1":33357,"de2":null}'
|
||||
@@ -44,7 +44,7 @@ INT,STRING
|
||||
---- QUERY
|
||||
# Querying two simple structs. There is a string in one of them and also a non-struct
|
||||
# string in the select list.
|
||||
select id, str, tiny_struct, small_struct from functional_orc_def.complextypes_structs;
|
||||
select id, str, tiny_struct, small_struct from complextypes_structs;
|
||||
---- RESULTS
|
||||
1,'first item','{"b":true}','NULL'
|
||||
2,'second item','{"b":false}','{"i":19191,"s":"small_struct_str"}'
|
||||
@@ -58,7 +58,7 @@ INT,STRING,STRING,STRING
|
||||
---- QUERY
|
||||
# Similar query as above but with an order by.
|
||||
select id, str, tiny_struct, small_struct
|
||||
from functional_orc_def.complextypes_structs
|
||||
from complextypes_structs
|
||||
order by id;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
1,'first item','{"b":true}','NULL'
|
||||
@@ -72,7 +72,7 @@ INT,STRING,STRING,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Querying the same struct multiple times in one query.
|
||||
select id, small_struct, small_struct from functional_orc_def.complextypes_structs;
|
||||
select id, small_struct, small_struct from complextypes_structs;
|
||||
---- RESULTS
|
||||
1,'NULL','NULL'
|
||||
2,'{"i":19191,"s":"small_struct_str"}','{"i":19191,"s":"small_struct_str"}'
|
||||
@@ -87,7 +87,7 @@ INT,STRING,STRING
|
||||
# The same struct multiple times in the select list where there is an ordering in the
|
||||
# results.
|
||||
select id, tiny_struct, tiny_struct
|
||||
from functional_orc_def.complextypes_structs
|
||||
from complextypes_structs
|
||||
order by id desc;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
6,'NULL','NULL'
|
||||
@@ -103,7 +103,7 @@ INT,STRING,STRING
|
||||
# Similar to the above query but here the 'id' field is not in the select list but still
|
||||
# used in the order by.
|
||||
select tiny_struct, tiny_struct
|
||||
from functional_orc_def.complextypes_structs
|
||||
from complextypes_structs
|
||||
order by id desc;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
'NULL','NULL'
|
||||
@@ -120,7 +120,7 @@ STRING,STRING
|
||||
# There are multiple string columns to check if none of the overwrites the other.
|
||||
# There is a row where all the children of the struct are null but the struct is non
|
||||
# null. Another row hold a struct that is itself null.
|
||||
select id, str, alltypes from functional_orc_def.complextypes_structs;
|
||||
select id, str, alltypes from complextypes_structs;
|
||||
---- RESULTS
|
||||
1,'first item','{"ti":100,"si":12348,"i":156789012,"bi":163234345342,"b":true,"f":1234.56005859375,"do":65323423.33,"da":"2021-05-30","ts":"2021-06-01 10:19:04","s1":"some string","s2":"another str","c1":"x","c2":"xyz","vc":"somevarcha","de1":12345,"de2":null}'
|
||||
2,'second item','{"ti":123,"si":4567,"i":1562322212,"bi":334333345342,"b":false,"f":NaN,"do":23233423.099,"da":null,"ts":"2020-06-11 12:10:04","s1":null,"s2":"NULL","c1":"a","c2":"ab ","vc":"varchar","de1":11223,"de2":null}'
|
||||
@@ -133,7 +133,7 @@ INT,STRING,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Similar query as above but with an order by.
|
||||
select id, str, alltypes from functional_orc_def.complextypes_structs order by id;
|
||||
select id, str, alltypes from complextypes_structs order by id;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
1,'first item','{"ti":100,"si":12348,"i":156789012,"bi":163234345342,"b":true,"f":1234.56005859375,"do":65323423.33,"da":"2021-05-30","ts":"2021-06-01 10:19:04","s1":"some string","s2":"another str","c1":"x","c2":"xyz","vc":"somevarcha","de1":12345,"de2":null}'
|
||||
2,'second item','{"ti":123,"si":4567,"i":1562322212,"bi":334333345342,"b":false,"f":NaN,"do":23233423.099,"da":null,"ts":"2020-06-11 12:10:04","s1":null,"s2":"NULL","c1":"a","c2":"ab ","vc":"varchar","de1":11223,"de2":null}'
|
||||
@@ -146,7 +146,7 @@ INT,STRING,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Similar query as above but with an order by desc.
|
||||
select id, str, alltypes from functional_orc_def.complextypes_structs order by id desc;
|
||||
select id, str, alltypes from complextypes_structs order by id desc;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
6,'sixth item','{"ti":127,"si":100,"i":234732212,"bi":664233223342,"b":true,"f":34.56000137329102,"do":99523423.33,"da":"1985-11-19","ts":"2020-09-15 03:11:22","s1":"string1","s2":"string2","c1":"z","c2":" ","vc":"cv","de1":346,"de2":6235.600}'
|
||||
5,'fifth item','NULL'
|
||||
@@ -160,7 +160,7 @@ INT,STRING,STRING
|
||||
---- QUERY
|
||||
# Setting BATCH_SIZE to force the results to fit in multiple row batches.
|
||||
set BATCH_SIZE=2;
|
||||
select id, str, alltypes from functional_orc_def.complextypes_structs;
|
||||
select id, str, alltypes from complextypes_structs;
|
||||
---- RESULTS
|
||||
1,'first item','{"ti":100,"si":12348,"i":156789012,"bi":163234345342,"b":true,"f":1234.56005859375,"do":65323423.33,"da":"2021-05-30","ts":"2021-06-01 10:19:04","s1":"some string","s2":"another str","c1":"x","c2":"xyz","vc":"somevarcha","de1":12345,"de2":null}'
|
||||
2,'second item','{"ti":123,"si":4567,"i":1562322212,"bi":334333345342,"b":false,"f":NaN,"do":23233423.099,"da":null,"ts":"2020-06-11 12:10:04","s1":null,"s2":"NULL","c1":"a","c2":"ab ","vc":"varchar","de1":11223,"de2":null}'
|
||||
@@ -175,7 +175,7 @@ INT,STRING,STRING
|
||||
# Querying struct in the select list and filter on one member of the struct.
|
||||
set BATCH_SIZE=0;
|
||||
select id, str, alltypes
|
||||
from functional_orc_def.complextypes_structs
|
||||
from complextypes_structs
|
||||
where alltypes.b = true;
|
||||
---- RESULTS
|
||||
1,'first item','{"ti":100,"si":12348,"i":156789012,"bi":163234345342,"b":true,"f":1234.56005859375,"do":65323423.33,"da":"2021-05-30","ts":"2021-06-01 10:19:04","s1":"some string","s2":"another str","c1":"x","c2":"xyz","vc":"somevarcha","de1":12345,"de2":null}'
|
||||
@@ -185,8 +185,19 @@ where alltypes.b = true;
|
||||
INT,STRING,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Filter on a column that is not a member of a struct. This triggers late materialization
|
||||
# where the SkipRows() functions of the struct readers could be exercised.
|
||||
select id, alltypes
|
||||
from complextypes_structs
|
||||
where id = 1;
|
||||
---- RESULTS
|
||||
1,'{"ti":100,"si":12348,"i":156789012,"bi":163234345342,"b":true,"f":1234.56005859375,"do":65323423.33,"da":"2021-05-30","ts":"2021-06-01 10:19:04","s1":"some string","s2":"another str","c1":"x","c2":"xyz","vc":"somevarcha","de1":12345,"de2":null}'
|
||||
---- TYPES
|
||||
INT,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Query a single struct slot.
|
||||
select alltypes from functional_orc_def.complextypes_structs;
|
||||
select alltypes from complextypes_structs;
|
||||
---- RESULTS
|
||||
'{"ti":100,"si":12348,"i":156789012,"bi":163234345342,"b":true,"f":1234.56005859375,"do":65323423.33,"da":"2021-05-30","ts":"2021-06-01 10:19:04","s1":"some string","s2":"another str","c1":"x","c2":"xyz","vc":"somevarcha","de1":12345,"de2":null}'
|
||||
'{"ti":123,"si":4567,"i":1562322212,"bi":334333345342,"b":false,"f":NaN,"do":23233423.099,"da":null,"ts":"2020-06-11 12:10:04","s1":null,"s2":"NULL","c1":"a","c2":"ab ","vc":"varchar","de1":11223,"de2":null}'
|
||||
@@ -199,7 +210,7 @@ STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Query a single struct slot and order by a member of the struct.
|
||||
select alltypes from functional_orc_def.complextypes_structs order by alltypes.si;
|
||||
select alltypes from complextypes_structs order by alltypes.si;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
'{"ti":127,"si":100,"i":234732212,"bi":664233223342,"b":true,"f":34.56000137329102,"do":99523423.33,"da":"1985-11-19","ts":"2020-09-15 03:11:22","s1":"string1","s2":"string2","c1":"z","c2":" ","vc":"cv","de1":346,"de2":6235.600}'
|
||||
'{"ti":123,"si":4567,"i":1562322212,"bi":334333345342,"b":false,"f":NaN,"do":23233423.099,"da":null,"ts":"2020-06-11 12:10:04","s1":null,"s2":"NULL","c1":"a","c2":"ab ","vc":"varchar","de1":11223,"de2":null}'
|
||||
@@ -212,7 +223,7 @@ STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Query struct slots only.
|
||||
select small_struct, alltypes from functional_orc_def.complextypes_structs;
|
||||
select small_struct, alltypes from complextypes_structs;
|
||||
---- RESULTS
|
||||
'NULL','{"ti":100,"si":12348,"i":156789012,"bi":163234345342,"b":true,"f":1234.56005859375,"do":65323423.33,"da":"2021-05-30","ts":"2021-06-01 10:19:04","s1":"some string","s2":"another str","c1":"x","c2":"xyz","vc":"somevarcha","de1":12345,"de2":null}'
|
||||
'{"i":19191,"s":"small_struct_str"}','{"ti":123,"si":4567,"i":1562322212,"bi":334333345342,"b":false,"f":NaN,"do":23233423.099,"da":null,"ts":"2020-06-11 12:10:04","s1":null,"s2":"NULL","c1":"a","c2":"ab ","vc":"varchar","de1":11223,"de2":null}'
|
||||
@@ -226,8 +237,8 @@ STRING,STRING
|
||||
---- QUERY
|
||||
# Query struct slot in a join query.
|
||||
select allt.id, comt.alltypes
|
||||
from functional_orc_def.alltypes allt
|
||||
join functional_orc_def.complextypes_structs comt on allt.id = comt.id;
|
||||
from alltypes allt
|
||||
join complextypes_structs comt on allt.id = comt.id;
|
||||
---- RESULTS
|
||||
1,'{"ti":100,"si":12348,"i":156789012,"bi":163234345342,"b":true,"f":1234.56005859375,"do":65323423.33,"da":"2021-05-30","ts":"2021-06-01 10:19:04","s1":"some string","s2":"another str","c1":"x","c2":"xyz","vc":"somevarcha","de1":12345,"de2":null}'
|
||||
2,'{"ti":123,"si":4567,"i":1562322212,"bi":334333345342,"b":false,"f":NaN,"do":23233423.099,"da":null,"ts":"2020-06-11 12:10:04","s1":null,"s2":"NULL","c1":"a","c2":"ab ","vc":"varchar","de1":11223,"de2":null}'
|
||||
@@ -241,8 +252,8 @@ INT,STRING
|
||||
---- QUERY
|
||||
# Similar join query as above but with different join order.
|
||||
select allt.id, comt.alltypes
|
||||
from functional_orc_def.complextypes_structs comt
|
||||
join functional_orc_def.alltypes allt on comt.id = allt.id;
|
||||
from complextypes_structs comt
|
||||
join alltypes allt on comt.id = allt.id;
|
||||
---- RESULTS
|
||||
1,'{"ti":100,"si":12348,"i":156789012,"bi":163234345342,"b":true,"f":1234.56005859375,"do":65323423.33,"da":"2021-05-30","ts":"2021-06-01 10:19:04","s1":"some string","s2":"another str","c1":"x","c2":"xyz","vc":"somevarcha","de1":12345,"de2":null}'
|
||||
2,'{"ti":123,"si":4567,"i":1562322212,"bi":334333345342,"b":false,"f":NaN,"do":23233423.099,"da":null,"ts":"2020-06-11 12:10:04","s1":null,"s2":"NULL","c1":"a","c2":"ab ","vc":"varchar","de1":11223,"de2":null}'
|
||||
@@ -256,7 +267,7 @@ INT,STRING
|
||||
---- QUERY
|
||||
# Querying IS NULL on a member of a struct.
|
||||
select id, str, alltypes
|
||||
from functional_orc_def.complextypes_structs
|
||||
from complextypes_structs
|
||||
where alltypes.da is null;
|
||||
---- RESULTS
|
||||
2,'second item','{"ti":123,"si":4567,"i":1562322212,"bi":334333345342,"b":false,"f":NaN,"do":23233423.099,"da":null,"ts":"2020-06-11 12:10:04","s1":null,"s2":"NULL","c1":"a","c2":"ab ","vc":"varchar","de1":11223,"de2":null}'
|
||||
@@ -270,7 +281,7 @@ INT,STRING,STRING
|
||||
# in the FROM clause. This also triggers a re-analysis of the statement as the table is
|
||||
# full ACID.
|
||||
select inner_arr.ITEM, inner_arr.ITEM.e, inner_arr.ITEM.f
|
||||
from functional_orc_def.complextypestbl.nested_struct.c.d.ITEM as inner_arr;
|
||||
from complextypestbl.nested_struct.c.d.ITEM as inner_arr;
|
||||
---- RESULTS
|
||||
'{"e":-1,"f":"nonnullable"}',-1,'nonnullable'
|
||||
'{"e":10,"f":"aaa"}',10,'aaa'
|
||||
@@ -288,7 +299,7 @@ from functional_orc_def.complextypestbl.nested_struct.c.d.ITEM as inner_arr;
|
||||
STRING,INT,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Similar to the above, but on a non-transactional version of the table.
|
||||
# Similar to the above, but on a non-transactional ORC version of the table.
|
||||
# Regression test for IMPALA-11011.
|
||||
select inner_arr.ITEM
|
||||
from functional_orc_def.complextypestbl_non_transactional.nested_struct.c.d.ITEM as inner_arr;
|
||||
@@ -312,7 +323,7 @@ STRING
|
||||
# Querying a struct that is inside a nested array. Referencing the inner array through a
|
||||
# join with the base table.
|
||||
select tbl.id, inner_arr.ITEM
|
||||
from functional_orc_def.complextypestbl tbl, tbl.nested_struct.c.d.ITEM as inner_arr;
|
||||
from complextypestbl tbl, tbl.nested_struct.c.d.ITEM as inner_arr;
|
||||
---- RESULTS
|
||||
8,'{"e":-1,"f":"nonnullable"}'
|
||||
1,'{"e":10,"f":"aaa"}'
|
||||
@@ -333,7 +344,7 @@ BIGINT,STRING
|
||||
# Querying a struct that is inside a nested array. Used 2 joins to reference the inner
|
||||
# array from the FROM clause.
|
||||
select tbl.id, inner_arr.ITEM
|
||||
from functional_orc_def.complextypestbl tbl,
|
||||
from complextypestbl tbl,
|
||||
tbl.nested_struct.c.d as outer_arr, outer_arr.ITEM as inner_arr;
|
||||
---- RESULTS
|
||||
8,'{"e":-1,"f":"nonnullable"}'
|
||||
@@ -355,7 +366,7 @@ BIGINT,STRING
|
||||
# Querying a struct that is inside a nested array. Used different kind of joins to
|
||||
# reference the inner array from the FROM clause.
|
||||
select tbl.id, inner_arr.ITEM
|
||||
from functional_orc_def.complextypestbl tbl left join
|
||||
from complextypestbl tbl left join
|
||||
tbl.nested_struct.c.d as outer_arr inner join outer_arr.ITEM as inner_arr;
|
||||
---- RESULTS
|
||||
8,'{"e":-1,"f":"nonnullable"}'
|
||||
@@ -376,7 +387,7 @@ BIGINT,STRING
|
||||
---- QUERY
|
||||
# Similar query as above but with an order by.
|
||||
select tbl.id, inner_arr.ITEM
|
||||
from functional_orc_def.complextypestbl tbl,
|
||||
from complextypestbl tbl,
|
||||
tbl.nested_struct.c.d as outer_arr, outer_arr.ITEM as inner_arr
|
||||
order by tbl.id;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
@@ -398,7 +409,7 @@ BIGINT,STRING
|
||||
---- QUERY
|
||||
# Structs are allowed in an inline view.
|
||||
select v.ts from
|
||||
(select tiny_struct as ts from functional_orc_def.complextypes_structs) v
|
||||
(select tiny_struct as ts from complextypes_structs) v
|
||||
---- RESULTS
|
||||
'{"b":true}'
|
||||
'{"b":false}'
|
||||
@@ -414,13 +425,13 @@ STRING
|
||||
select v.ts from
|
||||
(select int_struct_col as ts from functional.allcomplextypes) v
|
||||
---- CATCH
|
||||
AnalysisException: Querying STRUCT is only supported for ORC file format.
|
||||
AnalysisException: Querying STRUCT is only supported for ORC and Parquet file formats.
|
||||
====
|
||||
---- QUERY
|
||||
# Structs in an inline view with order by.
|
||||
select v.id, v.ts from
|
||||
(select id, tiny_struct as ts
|
||||
from functional_orc_def.complextypes_structs
|
||||
from complextypes_structs
|
||||
order by id
|
||||
limit 3) v
|
||||
---- RESULTS
|
||||
@@ -433,7 +444,7 @@ INT,STRING
|
||||
---- QUERY
|
||||
select v.id, v.ts from
|
||||
(select id, tiny_struct as ts
|
||||
from functional_orc_def.complextypes_structs
|
||||
from complextypes_structs
|
||||
order by id
|
||||
limit 3) v
|
||||
order by id desc
|
||||
@@ -447,7 +458,7 @@ INT,STRING
|
||||
---- QUERY
|
||||
select v.id, v.ts from
|
||||
(select id, tiny_struct as ts
|
||||
from functional_orc_def.complextypes_structs) v
|
||||
from complextypes_structs) v
|
||||
order by id desc
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
6,'NULL'
|
||||
@@ -461,9 +472,11 @@ INT,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# CREATE VIEW AS SELECT where the select returns struct.
|
||||
create view $DATABASE.struct_view as select id, small_struct
|
||||
from functional_orc_def.complextypes_structs;
|
||||
select id, small_struct from $DATABASE.struct_view;
|
||||
drop view if exists struct_view;
|
||||
create view struct_view as
|
||||
select id, small_struct
|
||||
from complextypes_structs;
|
||||
select id, small_struct from struct_view;
|
||||
---- RESULTS
|
||||
1,'NULL'
|
||||
2,'{"i":19191,"s":"small_struct_str"}'
|
||||
@@ -476,7 +489,7 @@ INT,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# WITH clause creates an inline view containing a struct.
|
||||
with sub as (select id, small_struct from functional_orc_def.complextypes_structs)
|
||||
with sub as (select id, small_struct from complextypes_structs)
|
||||
select sub.id, sub.small_struct from sub;
|
||||
---- RESULTS
|
||||
1,'NULL'
|
||||
@@ -493,7 +506,7 @@ INT,STRING
|
||||
# view and ordering by a non-complex item from the view.
|
||||
with sub as (
|
||||
select id, small_struct
|
||||
from functional_orc_def.complextypes_structs
|
||||
from complextypes_structs
|
||||
where small_struct.i > 19200)
|
||||
select sub.id, sub.small_struct from sub order by sub.id desc;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
@@ -504,8 +517,9 @@ INT,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Create a view containing structs and query the view.
|
||||
drop view if exists tmp_view;
|
||||
create view tmp_view as
|
||||
select id, str, tiny_struct, alltypes from functional_orc_def.complextypes_structs;
|
||||
select id, str, tiny_struct, alltypes from complextypes_structs;
|
||||
select id, alltypes, tiny_struct from tmp_view;
|
||||
---- RESULTS
|
||||
1,'{"ti":100,"si":12348,"i":156789012,"bi":163234345342,"b":true,"f":1234.56005859375,"do":65323423.33,"da":"2021-05-30","ts":"2021-06-01 10:19:04","s1":"some string","s2":"another str","c1":"x","c2":"xyz","vc":"somevarcha","de1":12345,"de2":null}','{"b":true}'
|
||||
@@ -520,33 +534,33 @@ INT,STRING,STRING
|
||||
---- QUERY
|
||||
# Query a struct from a partitioned table to check multi-fragment execution.
|
||||
set disable_outermost_topn = 1;
|
||||
select id, struct_val from functional_orc_def.alltypes_structs order by id desc limit 5;
|
||||
select id, struct_val from alltypes_structs order by id desc limit 5;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
7299,'{"bool_col":false,"tinyint_col":9,"smallint_col":9,"int_col":9,"bigint_col":90,"float_col":9.899999618530273,"double_col":90.89999999999999,"date_string_col":"12/31/10","string_col":"9","timestamp_col":"2010-12-31 05:09:13.860000000"}'
|
||||
7298,'{"bool_col":true,"tinyint_col":8,"smallint_col":8,"int_col":8,"bigint_col":80,"float_col":8.800000190734863,"double_col":80.8,"date_string_col":"12/31/10","string_col":"8","timestamp_col":"2010-12-31 05:08:13.780000000"}'
|
||||
7297,'{"bool_col":false,"tinyint_col":7,"smallint_col":7,"int_col":7,"bigint_col":70,"float_col":7.699999809265137,"double_col":70.7,"date_string_col":"12/31/10","string_col":"7","timestamp_col":"2010-12-31 05:07:13.710000000"}'
|
||||
7296,'{"bool_col":true,"tinyint_col":6,"smallint_col":6,"int_col":6,"bigint_col":60,"float_col":6.599999904632568,"double_col":60.59999999999999,"date_string_col":"12/31/10","string_col":"6","timestamp_col":"2010-12-31 05:06:13.650000000"}'
|
||||
7295,'{"bool_col":false,"tinyint_col":5,"smallint_col":5,"int_col":5,"bigint_col":50,"float_col":5.5,"double_col":50.5,"date_string_col":"12/31/10","string_col":"5","timestamp_col":"2010-12-31 05:05:13.600000000"}'
|
||||
7299,'{"bool_col":false,"tinyint_col":9,"smallint_col":9,"int_col":9,"bigint_col":90,"float_col":9.899999618530273,"double_col":90.89999999999999,"date_string_col":"12/31/10","string_col":"9"}'
|
||||
7298,'{"bool_col":true,"tinyint_col":8,"smallint_col":8,"int_col":8,"bigint_col":80,"float_col":8.800000190734863,"double_col":80.8,"date_string_col":"12/31/10","string_col":"8"}'
|
||||
7297,'{"bool_col":false,"tinyint_col":7,"smallint_col":7,"int_col":7,"bigint_col":70,"float_col":7.699999809265137,"double_col":70.7,"date_string_col":"12/31/10","string_col":"7"}'
|
||||
7296,'{"bool_col":true,"tinyint_col":6,"smallint_col":6,"int_col":6,"bigint_col":60,"float_col":6.599999904632568,"double_col":60.59999999999999,"date_string_col":"12/31/10","string_col":"6"}'
|
||||
7295,'{"bool_col":false,"tinyint_col":5,"smallint_col":5,"int_col":5,"bigint_col":50,"float_col":5.5,"double_col":50.5,"date_string_col":"12/31/10","string_col":"5"}'
|
||||
---- TYPES
|
||||
INT,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Query the same struct multiple times from a partitioned table.
|
||||
select id, struct_val, struct_val from functional_orc_def.alltypes_structs order by id limit 2;
|
||||
select id, struct_val, struct_val from alltypes_structs order by id limit 2;
|
||||
---- RESULTS: VERIFY_IS_EQUAL_SORTED
|
||||
0,'{"bool_col":true,"tinyint_col":0,"smallint_col":0,"int_col":0,"bigint_col":0,"float_col":0,"double_col":0,"date_string_col":"01/01/09","string_col":"0","timestamp_col":"2009-01-01 00:00:00"}','{"bool_col":true,"tinyint_col":0,"smallint_col":0,"int_col":0,"bigint_col":0,"float_col":0,"double_col":0,"date_string_col":"01/01/09","string_col":"0","timestamp_col":"2009-01-01 00:00:00"}'
|
||||
1,'{"bool_col":false,"tinyint_col":1,"smallint_col":1,"int_col":1,"bigint_col":10,"float_col":1.100000023841858,"double_col":10.1,"date_string_col":"01/01/09","string_col":"1","timestamp_col":"2009-01-01 00:01:00"}','{"bool_col":false,"tinyint_col":1,"smallint_col":1,"int_col":1,"bigint_col":10,"float_col":1.100000023841858,"double_col":10.1,"date_string_col":"01/01/09","string_col":"1","timestamp_col":"2009-01-01 00:01:00"}'
|
||||
0,'{"bool_col":true,"tinyint_col":0,"smallint_col":0,"int_col":0,"bigint_col":0,"float_col":0,"double_col":0,"date_string_col":"01/01/09","string_col":"0"}','{"bool_col":true,"tinyint_col":0,"smallint_col":0,"int_col":0,"bigint_col":0,"float_col":0,"double_col":0,"date_string_col":"01/01/09","string_col":"0"}'
|
||||
1,'{"bool_col":false,"tinyint_col":1,"smallint_col":1,"int_col":1,"bigint_col":10,"float_col":1.100000023841858,"double_col":10.1,"date_string_col":"01/01/09","string_col":"1"}','{"bool_col":false,"tinyint_col":1,"smallint_col":1,"int_col":1,"bigint_col":10,"float_col":1.100000023841858,"double_col":10.1,"date_string_col":"01/01/09","string_col":"1"}'
|
||||
---- TYPES
|
||||
INT,STRING,STRING
|
||||
====
|
||||
---- QUERY
|
||||
# Query struct from a partitioned table with where clause on the struct's members.
|
||||
select id, struct_val
|
||||
from functional_orc_def.alltypes_structs
|
||||
where struct_val.tinyint_col=8 and struct_val.timestamp_col > "2010-12-30";
|
||||
from alltypes_structs
|
||||
where struct_val.tinyint_col=8 and strleft(struct_val.date_string_col, 5) = "12/30";
|
||||
---- RESULTS
|
||||
7288,'{"bool_col":true,"tinyint_col":8,"smallint_col":8,"int_col":8,"bigint_col":80,"float_col":8.800000190734863,"double_col":80.8,"date_string_col":"12/30/10","string_col":"8","timestamp_col":"2010-12-30 04:58:13.330000000"}'
|
||||
7298,'{"bool_col":true,"tinyint_col":8,"smallint_col":8,"int_col":8,"bigint_col":80,"float_col":8.800000190734863,"double_col":80.8,"date_string_col":"12/31/10","string_col":"8","timestamp_col":"2010-12-31 05:08:13.780000000"}'
|
||||
7288,'{"bool_col":true,"tinyint_col":8,"smallint_col":8,"int_col":8,"bigint_col":80,"float_col":8.800000190734863,"double_col":80.8,"date_string_col":"12/30/10","string_col":"8"}'
|
||||
3638,'{"bool_col":true,"tinyint_col":8,"smallint_col":8,"int_col":8,"bigint_col":80,"float_col":8.800000190734863,"double_col":80.8,"date_string_col":"12/30/09","string_col":"8"}'
|
||||
---- TYPES
|
||||
INT,STRING
|
||||
====
|
||||
@@ -562,13 +576,13 @@ is not supported when querying STRUCT type STRUCT<f1:INT,f2:INT>
|
||||
# support selecting structs.
|
||||
create view tmp_view as select id, int_struct_col from functional.allcomplextypes;
|
||||
---- CATCH
|
||||
AnalysisException: Querying STRUCT is only supported for ORC file format.
|
||||
AnalysisException: Querying STRUCT is only supported for ORC and Parquet file formats.
|
||||
====
|
||||
---- QUERY
|
||||
# Querying IS NULL on a struct is not supported.
|
||||
# IMPALA-3060
|
||||
select id, str, alltypes
|
||||
from functional_orc_def.complextypes_structs
|
||||
from complextypes_structs
|
||||
where alltypes is null;
|
||||
---- CATCH
|
||||
AnalysisException: IS NULL predicate does not support complex types: alltypes IS NULL
|
||||
@@ -577,54 +591,54 @@ AnalysisException: IS NULL predicate does not support complex types: alltypes IS
|
||||
# Subquery that returns a complex type is not supported.
|
||||
# IMPALA-9500
|
||||
select alltypes
|
||||
from functional_orc_def.complextypes_structs
|
||||
where alltypes in (select alltypes from functional_orc_def.complextypes_structs);
|
||||
from complextypes_structs
|
||||
where alltypes in (select alltypes from functional_parquet.complextypes_structs);
|
||||
---- CATCH
|
||||
AnalysisException: A subquery can't return complex types. (SELECT alltypes FROM functional_orc_def.complextypes_structs)
|
||||
AnalysisException: A subquery can't return complex types. (SELECT alltypes FROM functional_parquet.complextypes_structs)
|
||||
====
|
||||
---- QUERY
|
||||
select tbl.nested_struct from functional_orc_def.complextypestbl tbl;
|
||||
select tbl.nested_struct from complextypestbl tbl;
|
||||
---- CATCH
|
||||
AnalysisException: Struct containing a collection type is not allowed in the select list.
|
||||
====
|
||||
---- QUERY
|
||||
select tbl.nested_struct.c from functional_orc_def.complextypestbl tbl;
|
||||
select tbl.nested_struct.c from complextypestbl tbl;
|
||||
---- CATCH
|
||||
AnalysisException: Struct containing a collection type is not allowed in the select list.
|
||||
====
|
||||
---- QUERY
|
||||
# Unioning structs is not supported.
|
||||
# IMPALA-10752
|
||||
select id, tiny_struct from functional_orc_def.complextypes_structs
|
||||
select id, tiny_struct from complextypes_structs
|
||||
union all
|
||||
select id, tiny_struct from functional_orc_def.complextypes_structs;
|
||||
select id, tiny_struct from complextypes_structs;
|
||||
---- CATCH
|
||||
AnalysisException: Set operations don't support STRUCT type. STRUCT<b:BOOLEAN> in tiny_struct
|
||||
====
|
||||
---- QUERY
|
||||
# Ordering by struct column is not supported.
|
||||
select id, tiny_struct from functional_orc_def.complextypes_structs
|
||||
select id, tiny_struct from complextypes_structs
|
||||
order by tiny_struct
|
||||
---- CATCH
|
||||
AnalysisException: ORDER BY expression 'tiny_struct' with complex type 'STRUCT<b:BOOLEAN>' is not supported.
|
||||
====
|
||||
---- QUERY
|
||||
# Ordering by struct column (using the index of the column) is not supported.
|
||||
select id, tiny_struct from functional_orc_def.complextypes_structs
|
||||
select id, tiny_struct from complextypes_structs
|
||||
order by 2
|
||||
---- CATCH
|
||||
AnalysisException: ORDER BY expression 'tiny_struct' with complex type 'STRUCT<b:BOOLEAN>' is not supported.
|
||||
====
|
||||
---- QUERY
|
||||
# Check that the order by don't confuse the 3rd column with the member of the struct.
|
||||
select id, tiny_struct from functional_orc_def.complextypes_structs
|
||||
select id, tiny_struct from complextypes_structs
|
||||
order by 3
|
||||
---- CATCH
|
||||
AnalysisException: ORDER BY: ordinal exceeds the number of items in the SELECT list: 3
|
||||
====
|
||||
---- QUERY
|
||||
# Structs inside arrays are not yet supported.
|
||||
select nested_struct.c.d from functional_orc_def.complextypestbl;
|
||||
select nested_struct.c.d from complextypestbl;
|
||||
---- CATCH
|
||||
AnalysisException: STRUCT type inside collection types is not supported.
|
||||
====
|
||||
|
||||
Reference in New Issue
Block a user