Impala Public Jenkins has submitted this change and it was merged. ( 
http://gerrit.cloudera.org:8080/24944 )

Change subject: IMPALA-15364: Reject ALTER TABLE ADD COLUMNS with NOT NULL and 
no default on Iceberg tables
......................................................................

IMPALA-15364: Reject ALTER TABLE ADD COLUMNS with NOT NULL and no default on 
Iceberg tables

Previously, ALTER TABLE ADD COLUMNS on an Iceberg table silently
accepted NOT NULL columns without a default value. The NOT NULL
constraint was then quietly dropped, making the column nullable.
This is incorrect because existing rows would have no valid value
for the new required column.

This patch adds an analysis-time check in AlterTableAddColsStmt
that rejects adding a NOT NULL column without a default value on
Iceberg tables, mirroring the existing validation for Kudu tables.
The error message is: "A new non-null column must have a default
value: <column definition>".

Note that since Iceberg v2 tables do not support default values,
this means NOT NULL columns cannot be added via ALTER TABLE on v2
tables at all. Users can either add the column as nullable, or
upgrade to format version 3 which supports default values:
  ALTER TABLE t ADD COLUMNS (j INT NOT NULL DEFAULT 0)

Testing:
- Updated AnalyzeDDLTest#TestAlterTableAddColumn to expect an
  AnalysisError for NOT NULL without default on Iceberg.
- Added a new AnalysisError case in TestAlterTableAddColumns for
  multi-column ADD COLUMNS on Iceberg.
- Added an end-to-end test case in iceberg-alter-v2.test.

Change-Id: I9bf294664ef83d26ca90db28df0993805d5ce67e
Assisted-by: Claude Opus 4.6 (Claude Code)
Reviewed-on: http://gerrit.cloudera.org:8080/24944
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
---
M fe/src/main/java/org/apache/impala/analysis/AlterTableAddColsStmt.java
M fe/src/test/java/org/apache/impala/analysis/AnalyzeDDLTest.java
M testdata/workloads/functional-query/queries/QueryTest/iceberg-alter-v2.test
3 files changed, 23 insertions(+), 4 deletions(-)

Approvals:
  Impala Public Jenkins: Looks good to me, approved; Verified

--
To view, visit http://gerrit.cloudera.org:8080/24944
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9bf294664ef83d26ca90db28df0993805d5ce67e
Gerrit-Change-Number: 24944
Gerrit-PatchSet: 4
Gerrit-Owner: Nandor Kollar <[email protected]>
Gerrit-Reviewer: Csaba Ringhofer <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Nandor Kollar <[email protected]>
Gerrit-Reviewer: Peter Rozsa <[email protected]>

Reply via email to