#20576·databend

Feature: avoid data rewrite for safe ALTER TABLE MODIFY COLUMN type widening

Author: dantengskyCreated Sep 24, 2026Updated Sep 29, 2026
LabelsC-feature

Motivation

ALTER TABLE ... MODIFY COLUMN can be prohibitively expensive on large tables when it rewrites every block even though an old physical value can be interpreted losslessly as the new logical type. For supported cases, avoid the rewrite rather than only making the rewrite faster.

Requested behavior

For Fuse/Parquet tables, allow a metadata-only column type change only when existing blocks remain readable with the new schema and subsequent operations preserve correctness. Candidate cases include lossless numeric widening (e.g. Int32 -> Int64) and Decimal precision widening with unchanged scale. Existing STRING -> BINARY handling is another relevant case. This is not a request to skip rewriting for arbitrary casts: Decimal scale changes, lossy conversions, unsupported encodings/types, and changes requiring recomputation must continue to use the safe rewrite path.

Reads must work for both old and newly written blocks, including predicates and pruning. Account for mixed-type block/segment statistics, range/page and bloom indexes, compaction/recluster, defaults and nested types where supported. If a change cannot be proven safe for no-rewrite, preserve its existing behavior: rewrite when the conversion is supported, or reject it when invalid; never silently reinterpret old blocks.

Acceptance criteria

  • Document and enforce the precise eligibility conditions (type, format, and schema-change semantics).
  • On eligible changes, avoid full-table block rewriting; preserve correct reads, filters/pruning and subsequent writes/maintenance over old and new blocks.
  • Changes ineligible for no-rewrite retain existing semantics: supported conversions use the rewrite path (e.g. Decimal scale changes), while invalid conversions still fail.
  • Regression tests cover mixed old/new blocks, index/statistics behavior, nested or nullable cases if supported, and at least one negative case (e.g. Decimal scale change).

Related work

  • Draft implementation: #19419 (safe no-rewrite widening). The implementation and its exact supported cases remain subject to review; this issue tracks the requirement separately from that PR.
  • Separate requirement: #20575 tracks distributed execution when rewriting is unavoidable. Neither item replaces the other.