Feature: distribute ALTER TABLE MODIFY COLUMN data rewrite across nodes
Summary
When ALTER TABLE ... MODIFY COLUMN requires rewriting a Fuse table, allow the rewrite's schema conversion and data writes to run across query nodes, while keeping the final table/snapshot commit coordinated. This matters for very large tables on multi-node warehouses.
Current behavior (code inspection)
build_select_insert_plan in src/query/service/src/interpreters/interpreter_table_modify_column.rs constructs a physical plan with DistributedInsertSelect above the full select_plan. If that SELECT has a top-level Merge exchange, its scan/source can be distributed but DistributedInsertSelect executes in the root fragment on the coordinator. Its pipeline applies TransformCastSchema (when needed), prepares rows, and calls table.append_data there (src/query/service/src/physical_plans/physical_distributed_insert_select.rs). Thus a rewrite may funnel rows through one node for conversion and writing, even if the source scan is distributed. This does not imply one thread or that all ALTER cases rewrite data.
By contrast, ordinary INSERT ... SELECT uses build_insert_select_physical_plan (src/query/service/src/interpreters/interpreter_insert.rs), which moves DistributedInsertSelect under a top-level Merge exchange for tables supporting distributed insert; the Merge gathers write/commit metadata back to the coordinator. Fuse supports distributed insert.
A reported multi-node, very-large-table MODIFY COLUMN operation appeared to use mainly one node and had hours remaining.
Expected behavior
- For rewrite-requiring column modifications on a distributed warehouse, run applicable conversion/preparation and block writes on multiple nodes when supported, gather write metadata, and commit the new schema/snapshot safely once.
- Preserve local/single-node fallbacks and metadata-only ALTER behavior; preserve atomicity and existing failure/rollback semantics.
- Cover distributed vs local plans and correctness of rewritten data/schema with regression tests (including casts and failure handling).
The existing distributed INSERT ... SELECT path may be reusable, but the ALTER-specific snapshot/schema commit and concurrent-change checks need review before adopting it.
Source: databendlabs/databend