Arnab Karmakar has uploaded this change for review. ( 
http://gerrit.cloudera.org:8080/25183


Change subject: IMPALA-15615: Create required fields for NOT NULL columns in 
Iceberg ADD COLUMN
......................................................................

IMPALA-15615: Create required fields for NOT NULL columns in Iceberg ADD COLUMN

ALTER TABLE ... ADD COLUMN(S) on an Iceberg V3 table silently dropped
NOT NULL when the column had a DEFAULT. The new column was added as an
optional field ("required":false), DESCRIBE showed it as nullable, and
NULL could be inserted into it. CREATE TABLE with the same column
definition correctly produced a required field.

Since IMPALA-15364, analysis rejects a NOT NULL column without a
DEFAULT, and a DEFAULT requires 'format-version' >= 3. So a NOT NULL
column only reaches the catalog on V3 tables, and always with a DEFAULT.
IcebergCatalogOpExecutor.addColumns() ignored TColumn.is_nullable and
always called UpdateSchema.addColumn().

This patch makes addColumns() call UpdateSchema.addRequiredColumn() when
is_nullable is set to false, passing the default literal when there is
one. Iceberg allows adding a required column when it has a default, so
no allowIncompatibleChanges() is needed. Existing rows read the
initial-default and INSERTs that omit the column get the write-default
while nullable columns still use addColumn() as before.

Testing:
- Added e2e tests to iceberg-v3-default-values.test for ADD COLUMN and
  ADD COLUMNS with NOT NULL DEFAULT:
  * DESCRIBE shows nullable=false
  * existing rows read the initial-default
  * INSERT omitting the columns gets the write-default
  * INSERT of explicit NULL fails

Change-Id: Idd7e882b1fd86f60fede0964dbcad1a55bea3691
Assisted-by: Claude Sonnet 5.5 (Cursor)
---
M fe/src/main/java/org/apache/impala/service/IcebergCatalogOpExecutor.java
M 
testdata/workloads/functional-query/queries/QueryTest/iceberg-v3-default-values.test
2 files changed, 52 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/83/25183/1
--
To view, visit http://gerrit.cloudera.org:8080/25183
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idd7e882b1fd86f60fede0964dbcad1a55bea3691
Gerrit-Change-Number: 25183
Gerrit-PatchSet: 1
Gerrit-Owner: Arnab Karmakar <[email protected]>

Reply via email to