25.8: Fix Nullable(X)->Y cross-type ALTER MODIFY COLUMN (follow-up to #84770)#1612
25.8: Fix Nullable(X)->Y cross-type ALTER MODIFY COLUMN (follow-up to #84770)#1612il9ue wants to merge 1 commit intoreleases/25.8.16from
Conversation
ContextThis is a follow-up fix for the backport of upstream ClickHouse/ClickHouse#84770 ("Handle NULLs in ALTER MODIFY COLUMN"), which was backported to Altinity 24.8 via #1370 and to 25.8 via #1344. ProblemPR ClickHouse#84770 correctly handles Reproducer: CREATE TABLE XXX (x Nullable(UInt8), y String) ENGINE=MergeTree ORDER BY tuple();
INSERT INTO XXX (y) VALUES (1);
ALTER TABLE XXX MODIFY COLUMN x String DEFAULT '';
-- FAILS: NO_COMMON_TYPE errorThis was reported by a customer on Altinity Stable 24.8.14. The same failure is reproducible on upstream v26.1.6.6 (ClickHouse Playground), while v26.2.5.45 succeeds. Root Cause
When converting Why cherry-picking the upstream fix (PR ClickHouse#96790) is not sufficientUpstream resolved this in ClickHouse/ClickHouse#96790 by modifying However, on Altinity 24.8 and 25.8, FixInstead of modifying Before (broken for cross-type): After (works for all type combinations): This works because:
Scope
BranchesThis fix applies to both Altinity branches that have PR ClickHouse#84770:
Altinity 25.3 does not have ClickHouse#84770 and is not affected. |
PR ClickHouse#84770 generates _CAST(ifNull(col, default), TargetType). When source and target base types differ (e.g. Nullable(UInt8) -> String), ifNull throws NO_COMMON_TYPE because getLeastSupertype({UInt8, String}) fails. Fix: swap to ifNull(_CAST(col, Nullable(TargetType)), _CAST(default, TargetType)). Ref: ClickHouse#84770, ClickHouse#5985 Signed-off-by: Daniel Q. Kim <daniel.kim@altinity.com>
fd1a650 to
c613cbf
Compare
Updated: moved test to a separate file to fix CI failuresThe -- { echoOff } directive didn't suppress SQL echo as expected because the original test (03575_modify_column_null_to_default.sql) runs in -- { echoOn } mode throughout. Appended test lines were being echoed to stdout, causing a mismatch with the .reference file. What changed in this amend:
Other CI failures are pre-existing and unrelated to this PR:
|
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix
ALTER MODIFY COLUMNfailure when converting nullable columns to a different non-nullable type (e.g.Nullable(UInt8)toString). Previously, cross-type nullable conversions would fail withNO_COMMON_TYPEerror. Follow-up to upstream ClickHouse#84770.CI/CD Options
Exclude tests:
Regression jobs to run: