fix: include NULL in delete predicate for evolved partition fields in dynamic_partition_overwrite#3460
Conversation
|
@GayathriSrividya Thanks for opening this PR, but I think you've pulled in some unrelated commits here |
Thanks, @Fokko. Could you please point out which commits look unrelated? I’ll clean up the branch and keep this PR focused only on the #3148 fix. Or I will close this and open fresh PR |
|
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions. |
0567a6e to
e015a56
Compare



Closes #3148
Root cause
dynamic_partition_overwritebuilds its delete predicate using the current partition spec only:After a partition spec evolution (e.g. adding a
regionfield), data files written under the older spec carryNULLfor the new field — becauseregionsimply wasn't part of the schema at write time.The predicate produced for the new partition
{category=A, region=us}is:The
_StrictMetricsEvaluatorcorrectly sees that spec-0 files haveregion = NULLfor every row, soregion = 'us'can never beROWS_MUST_MATCH. Those files are silently kept, leaving stale data behind.Fix
Detect which fields in the current spec were absent from at least one historical spec ("evolved" fields). For those fields, extend the per-field clause to also accept
NULL:This causes the metrics evaluator to flag pre-evolution files (all-null
region) asROWS_MUST_MATCHand delete them, while correctly preserving files in other non-overlapping partitions (e.g.region = 'eu').Verification
Added two unit tests for
_build_partition_predicate(with / withoutevolved_source_ids) and manually confirmed the repro from the issue now produces[999]instead of[1, 2, 999].