set_cluster_columns
Change or remove clustering columns on a table by rebuilding it transactionally with a CTAS-swap, ensuring no orphan tables on failure.
Instructions
Change (or remove) the data-clustering columns of an existing table.
Rebuilds the table via a transactional CTAS-swap:
CREATE TABLE [schema].[__recluster_<hex>] [WITH (CLUSTER BY (...))] AS SELECT * FROM [schema].[orig]DROP TABLE [schema].[orig]EXEC sp_renameto restore the original name
All three steps run inside ONE transaction. Any failure rolls back automatically — no orphan temp table is left behind.
CAUTION: This operation copies the full table (runtime is proportional
to table size). Dependent views and stored procedures that reference
this table by name are NOT automatically updated by sp_rename and
may need refreshing after the swap.
Only supported on Fabric Data Warehouses (not SQL Analytics Endpoints).
Args:
workspace: Workspace name or GUID.
item: Warehouse name or GUID. SQL Analytics Endpoints are rejected.
qualified_name: Dot-separated qualified table name, e.g. dbo.sales.
cluster_by: New list of column names for the CLUSTER BY clause
(up to 4). Pass null or an empty list to remove clustering
(rebuilds table without CLUSTER BY).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| item | Yes | ||
| workspace | Yes | ||
| cluster_by | No | ||
| qualified_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||