Z-ordering feature
Hive supports Z-ordering for Iceberg tables in CREATE TABLE and
INSERT statements. Z-order indexing improves data clustering and query
performance on Iceberg tables.
Z-ordering is a technique that clusters related values in data files. From Hive, specify Z-order columns when you create an Iceberg table or when you insert data into a table that was created with a Z-order write order.
Use WRITE [LOCALLY] ORDERED BY ZORDER in the CREATE [EXTERNAL]
TABLE statement. List the columns to include in the Z-order index in the
ZORDER clause.
Hive examples
In the following example, Hive creates an Iceberg table stored as ORC and applies
Z-ordering on the id and text columns during the initial
table write:
CREATE TABLE test_zorder (
id INT,
text STRING)
WRITE [LOCALLY] ORDERED BY ZORDER (id, text)
STORED BY ICEBERG
STORED AS ORC;
In the following example, when you load data with INSERT or INSERT
OVERWRITE into a Z-order Iceberg table, Hive applies the same Z-order layout
defined at table creation:
INSERT INTO test_zorder VALUES (1, 'sample');
INSERT OVERWRITE TABLE test_zorder
SELECT id, text FROM source_table;
