Updated on 2026-11-06 GMT+08:00

Liquid Clustering Usage

Liquid Clustering Configuration

Liquid Clustering is configured using Iceberg table properties.

CREATE TABLE events (
    event_id BIGINT,
    user_id BIGINT,
    event_type STRING,
    event_time TIMESTAMP,
    payload STRING
)
USING iceberg
TBLPROPERTIES (
    'format-version' = '2',
    'write.liquid-clustering.columns' = 'user_id,event_time'
);

Specifying Custom Cube Size

CREATE TABLE logs (
    log_id BIGINT,
    service_name STRING,
    log_level STRING,
    message STRING,
    timestamp TIMESTAMP
)
USING iceberg
TBLPROPERTIES (
    'format-version' = '2',
    'write.liquid-clustering.columns' = 'service_name,timestamp',
    'write.liquid-clustering.target-cube-size-bytes' = '21474836480',
    'write.liquid-clustering.min-cube-size-bytes' = '5368709120'
);

Note: Set target-cube-size-bytes to 20 GB (21,474,836,480 bytes) and min-cube-size-bytes to 5 GB (5,368,709,120 bytes).

Modifying Liquid Clustering Configuration

-- Modify the clustering columns (only adding is supported; deleting existing clustering columns is not supported).
ALTER TABLE events SET TBLPROPERTIES ('write.liquid-clustering.columns' = 'user_id,event_time,event_type');

-- Adjust the target Cube size.
ALTER TABLE events SET TBLPROPERTIES ('write.liquid-clustering.target-cube-size-bytes' = '32212254720');

-- Adjust the minimum Cube threshold.
ALTER TABLE events SET TBLPROPERTIES ('write.liquid-clustering.min-cube-size-bytes' = '10737418240');

Triggering Cube Rewriting

-- Rewrite all Cubes marked as Partial.
CALL spark_catalog.system.rewrite_data_files(
    table => 'db.events',
    options => map('rewrite-all', 'false')
);

-- Rewrite all Cubes (including healthy Cubes).
CALL spark_catalog.system.rewrite_data_files(
    table => 'db.events',
    options => map('rewrite-all', 'true')
);