mirror of
https://github.com/apache/impala.git
synced 2026-02-01 21:00:29 -05:00
Extended the SQL grammar with an optional and a default flag for SORT BY, namely ZORDER and LEXICAL. If set, the new 'sort.algorithm' table property will be set to ZORDER and the information will sink down to the backend. The default order is indicated by LEXICAL and can be omitted. Examples are: CREATE TABLE t (a INT, b INT) PARTITIONED BY (c INT) SORT BY ZORDER (a, b); CREATE TABLE t SORT BY ZORDER (int_col,id) LIKE u; CREATE TABLE t LIKE PARQUET '/foo' SORT BY ZORDER (id,zip); ALTER TABLE t SORT BY ZORDER (int_col,id); The following two are the same statements: CREATE TABLE t (a INT, b INT) SORT BY (a, b); CREATE TABLE t (a INT, b INT) SORT BY LEXICAL (a, b); For strings, varchars, floats and doubles Z-ordering is currently not supported. It's not suitable for strings and varchars, but support can be added for floats and doubles later. The supported types are: boolean, int types, decimals, date, timestamp, and char. Currently ZORDER has the same functionality as a simple SORT BY clause, therefore hidden behind a feature flag: unlock_zorder. The custom sorting with Z-ordering will be in a different commit later. Testing: * Added tests for the ZORDER option for every SORT BY test. * Modified some tests by adding the LEXICAL option. * The .test workloads are temporarily put in separate test files in order to set up the feature flag. These tests are run from tests/custom_cluster/test_zorder.py which is a duplication of the relevant tests, but with CustomClusterTestSuite decorator. Change-Id: Ie122002ca8f52ca2c1e1ec8ff1d476ae1f4f875d Reviewed-on: http://gerrit.cloudera.org:8080/13955 Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
26 lines
635 B
Plaintext
26 lines
635 B
Plaintext
====
|
|
---- CREATE_TABLE
|
|
# Simple table with zsort columns.
|
|
CREATE TABLE test1 (id INT, z INT)
|
|
SORT BY ZORDER (id, z)
|
|
STORED AS TEXTFILE
|
|
---- RESULTS
|
|
CREATE TABLE show_create_table_test_db.test1 (id INT, z INT)
|
|
SORT BY ZORDER (id, z)
|
|
STORED AS TEXTFILE
|
|
LOCATION '$$location_uri$$'
|
|
====
|
|
---- CREATE_TABLE
|
|
# Simple partitioned table with zsort columns.
|
|
CREATE TABLE test1 (id INT, z INT)
|
|
PARTITIONED BY (x INT, y INT)
|
|
SORT BY ZORDER (id, z)
|
|
STORED AS TEXTFILE
|
|
---- RESULTS
|
|
CREATE TABLE show_create_table_test_db.test1 (id INT, z INT)
|
|
PARTITIONED BY (x INT, y INT)
|
|
SORT BY ZORDER (id, z)
|
|
STORED AS TEXTFILE
|
|
LOCATION '$$location_uri$$'
|
|
====
|