Hello Impala Public Jenkins,

I'd like you to reexamine a change. Please visit

    https://gerrit.cloudera.org/25454

to look at the new patch set (#3).

Change subject: IMPALA-15793: Fix DML on Iceberg partitions with a dropped 
source column
......................................................................

IMPALA-15793: Fix DML on Iceberg partitions with a dropped source column

After the partition spec of an Iceberg table changed and the source
column of a partition field of an old spec was dropped, DELETE, UPDATE
and MERGE on rows in data files of the old spec didn't take effect in
release builds: the statements reported success, but the deleted rows
stayed in the table, in Impala and in other engines. In debug builds
impalad crashed on a DCHECK in the delete sink.

Since IMPALA-13591, Impala describes a partition field whose source
column was dropped as VOID, but the scan still serialized its value for
the delete sink (ICEBERG__PARTITION__SERIALIZED), so the delete sink got
a partition value for a VOID field. Release builds committed the delete
file with a null partition value. Iceberg types such a field as unknown,
and doesn't match partition-scoped position deletes of the spec to its
data files, whatever their partition value. Only deletes that reference
a single data file are matched, by path. Impala writes the position
deletes of a partition into one delete file, so a statement that deleted
rows from several data files of such a partition had no effect with
format version 2. Deletion vectors always reference a single data file.

The fix:
 - The scan skips the partition fields that are VOID in the partition
   spec of Impala when it serializes the partition values for the
   delete sink, like the fields with a void transform. The file
   metadata keeps the values of these fields, as the scans need them,
   e.g. for time travel, and for migrated tables, whose data files
   don't contain the partition columns.
 - The delete sink writes one position delete file per data file in
   the specs with such a field, and in the current spec if the delete
   has no partition key exprs, as then every delete file gets the
   current spec id. The specs are sent in the new
   TIcebergDeleteSink.file_scoped_spec_ids.
 - The commit builds the partition data of such specs with null for
   the VOID fields, instead of no partition data.
 - A position delete file whose deletes reference a single data file
   gets referenced_data_file, so readers don't need its bounds to
   match it. lookupDeletionVectors() only collects deletion vectors.
 - The delete sink returns an error instead of a DCHECK when the
   partition values don't match the partition spec.

Also removes the unused Table parameter of
IcebergUtil.createIcebergMetadata() and redundant ByteBuffer casts.

Delete files committed before this fix stay ineffective; the affected
statements have to be run again.

Testing:
 - Added EE tests to iceberg-alter-v2.test for DELETE, UPDATE and MERGE
   on data files of a spec with a dropped source column, with format
   version 2 and 3, with and without a predicate on a partition
   column: an unpartitioned current spec, a spec with two fields of
   which one is dropped, a deletion vector replaced by a second DELETE,
   a column added again with the same name, BUCKET and DAY transforms
   with the columns dropped one by one, and the referenced_data_file of
   position delete files. They failed before the fix.
 - Added test_migrated_table_drop_old_partition_col: a migrated table
   with complex types, whose data file doesn't contain the dropped
   partition column, is read correctly, also with time travel to a
   snapshot before the column was dropped.
 - Added IcebergDroppedPartitionSourceTest for the partition specs with
   a dropped source column, the serialized partition values of their
   data files and the partition data of delete files.
 - test_iceberg.py tests about DELETE, UPDATE, MERGE, OPTIMIZE,
   partitions, ALTER, migrated tables, time travel and format version 3
   pass, except test_v3_variant* (missing test data) and
   test_metadata_tables, which fail without this change too.

Change-Id: I03ae34cb19197e9d711fc462c4bcf6f050291648
Assisted-by: Claude Opus 5.5 (Claude Code)
---
M be/src/exec/file-metadata-utils.cc
M be/src/exec/iceberg-buffered-delete-sink.cc
M be/src/exec/iceberg-buffered-delete-sink.h
M be/src/exec/iceberg-delete-sink-base.cc
M be/src/exec/iceberg-delete-sink-base.h
M be/src/exec/iceberg-delete-sink-config.cc
M be/src/exec/iceberg-delete-sink-config.h
M common/thrift/DataSinks.thrift
M fe/src/main/java/org/apache/impala/catalog/IcebergFileMetadataLoader.java
M fe/src/main/java/org/apache/impala/planner/IcebergBufferedDeleteSink.java
M fe/src/main/java/org/apache/impala/planner/IcebergScanPlanner.java
M fe/src/main/java/org/apache/impala/service/IcebergCatalogOpExecutor.java
M fe/src/main/java/org/apache/impala/util/IcebergUtil.java
A fe/src/test/java/org/apache/impala/util/IcebergDroppedPartitionSourceTest.java
M testdata/workloads/functional-query/queries/QueryTest/iceberg-alter-v2.test
M tests/query_test/test_iceberg.py
16 files changed, 733 insertions(+), 33 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/54/25454/3
--
To view, visit https://gerrit.cloudera.org/25454
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I03ae34cb19197e9d711fc462c4bcf6f050291648
Gerrit-Change-Number: 25454
Gerrit-PatchSet: 3
Gerrit-Owner: Nandor Kollar <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>

Reply via email to