ALTER TABLE CLUSTER BY

Configures or disables liquid clustering on a Delta table.

Category: ddlDeltaForge extension

Syntax

ALTER TABLE <table> CLUSTER BY (<columns>) | CLUSTER BY NONE

Description

## Overview Configures liquid clustering on an existing Delta table. Liquid clustering replaces traditional ZORDER BY with an incremental, automatic clustering strategy. When clustering columns are defined, OPTIMIZE operations will co-locate data by those columns using Hilbert curves, significantly improving query performance for predicates on the clustering keys. ## Behavior - When CLUSTER BY (columns) is specified, the clustering columns are stored as Delta table metadata. Subsequent OPTIMIZE operations will use these columns to cluster new and modified data files. - When CLUSTER BY NONE is specified, clustering is disabled. The clustering column metadata is removed. Previously clustered files are not affected, but new OPTIMIZE operations will not apply clustering. - Changing the clustering columns replaces the previous configuration entirely. There is no incremental add/remove of clustering keys. - The operation writes a metadata-only commit to the Delta log. No data files are rewritten at the time of the ALTER; actual clustering happens during the next OPTIMIZE run. - Column names are normalized to lowercase to match DeltaForge's schema normalization behavior. ## Compatibility Liquid clustering is a DeltaForge extension. The clustering metadata is stored as table properties. Tables with liquid clustering enabled require Delta readers that support the liquid clustering protocol feature.

Parameters

NameTypeDescription
tableFully qualified table name or registered table name. The table must be registered in the current session.
columnsClustering columns. Empty = disable clustering.

Examples

-- Enable liquid clustering on a single column
ALTER TABLE warehouse.sales.orders CLUSTER BY (order_date);
-- Enable multi-column clustering
ALTER TABLE warehouse.sales.events CLUSTER BY (event_type, event_date);
-- Change clustering columns
ALTER TABLE warehouse.sales.orders CLUSTER BY (customer_id, order_date);
-- Disable clustering
ALTER TABLE warehouse.sales.orders CLUSTER BY NONE;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →