Files
impala/testdata/workloads/functional-query/queries/QueryTest/top-n-complex.test
Daniel Becker ff3d0c7984 IMPALA-12019: Support ORDER BY for arrays of fixed length types in select list
As a first stage of IMPALA-10939, this change implements support for
including in the sorting tuple top-level collections that only contain
fixed length types (including fixed length structs). For these types the
implementation is almost the same as the existing handling of strings.

Another limitation is that structs that contain any type of collection
are not yet allowed in the sorting tuple.

Also refactored the RawValue::Write*() functions to have a clearer
interface.

Testing:
 - Added a new test table that contains many rows with arrays. This is
   queried in a new test added in test_sort.py, to ensure that we handle
   spilling correctly.
 - Added tests that have arrays and/or maps in the sorting tuple in
   test_queries.py::TestQueries::{test_sort,
       test_top_n,test_partitioned_top_n}.

Change-Id: Ic7974ef392c1412e8c60231e3420367bd189677a
Reviewed-on: http://gerrit.cloudera.org:8080/19660
Reviewed-by: Csaba Ringhofer <csringhofer@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2023-05-18 09:56:55 +00:00

67 lines
1.8 KiB
Plaintext

====
---- QUERY
# Sort a collection with limit.
select id, int_array from complextypestbl order by id limit 5
---- RESULTS
1,'[1,2,3]'
2,'[null,1,2,null,3,null]'
3,'[]'
4,'NULL'
5,'NULL'
---- TYPES
bigint,string
====
---- QUERY
# Sort collection from nested query inline view with limit.
select id, int_array
from (select id, int_array from complextypestbl) v
order by id limit 5
---- RESULTS
1,'[1,2,3]'
2,'[null,1,2,null,3,null]'
3,'[]'
4,'NULL'
5,'NULL'
---- TYPES
bigint,string
====
---- QUERY
# Sort a collection that is join-unnested in a nested query inline view with limit.
select id, arr
from (
select id, a.item arr
from complextypestbl t, t.int_array_array a
) v
order by id limit 2;
---- RESULTS
1,'[1,2]'
1,'[3,4]'
---- TYPES
bigint,string
====
---- QUERY
# Sorting with limit is not supported yet for arrays containing varlen types: IMPALA-10939
select id, arr_string_1d from collection_tbl order by id limit 2;
---- CATCH
AnalysisException: Sorting is not supported if the select list contains (possibly nested) collections with variable length data types.
====
---- QUERY
# Sorting with limit is not supported yet for arrays containing varlen types: IMPALA-10939
select id, int_array_array from complextypestbl order by id limit 2;
---- CATCH
AnalysisException: Sorting is not supported if the select list contains (possibly nested) collections with variable length data types.
====
---- QUERY
# Being in the sorting tuple is supported for maps containing only fixed length types,
# also with limit:
# IMPALA-10939
select id, map_int_int, map_char3_char5 from map_non_varlen order by id desc limit 4
---- RESULTS
10,'{100:1000,101:1010,102:1020}','{"aaj":"aaaaj"}'
9,'{90:900,91:910,92:920}','{"aai":"aaaai"}'
8,'{80:800,81:810,82:820}','{"aah":"aaaah"}'
7,'{70:700,71:710,72:720}','{"aag":"aaaag"}'
---- TYPES
int,string,string
====