[AMORO-4044] Return correct partition for delete files in iceberg tables whose partition spec have changed#4047
[AMORO-4044] Return correct partition for delete files in iceberg tables whose partition spec have changed#4047juiceyang wants to merge 1 commit intoapache:masterfrom
Conversation
…les whose partition spec have changed
1e98195 to
d299386
Compare
|
I ran the I also noticed that others have reported similar failures: issue-3985 |
|
Hi @juiceyang, thanks for working on this issue! I've been looking into the same problem. I think the root cause is actually in TableEntriesScan itself — the entries metadata table returns a unified partition struct containing fields from all PartitionSpecs, but buildDataFile() and buildDeleteFile() pass this directly to withPartition() without projecting it to the spec-specific partition type. Your current approach works around this in getDanglingDeleteFiles() by reading manifests directly, but other callers of TableEntriesScan would still hit the same issue. I'd like to submit a fix at the TableEntriesScan level to address the root cause. Would that be okay with you, or would you prefer to update this PR to fix it there instead? |
Hi @j1wonpark! I agree that root cause is in TableEntriesScan. I’ve only changed one spot for now, mainly to keep the change as small as possible and minimize impact. If you can fix it at the TableEntriesScan level, that would be a better and more thorough solution. Please go ahead and submit a separate PR following your approach. Once your PR fixes the issue, I’ll close mine. This problem has been bothering us for a while—thanks a lot for your work and contribution! |
Why are the changes needed?
According to org.apache.iceberg.BaseEntriesTable#schema, in org.apache.amoro.scan.TableEntriesScan#entries, the partition field in the fileRecord includes values for all PartitionSpec columns. Therefore, when org.apache.amoro.scan.TableEntriesScan#buildDeleteFile creates a DeleteFile using that fileRecord, if the fileRecord was written with a newer PartitionSpec, then inside org.apache.iceberg.DataFiles#copyPartitionData the partition fields from the older PartitionSpec will overwrite the PartitionSpec columns. This eventually causes the partition field of the created DeleteFile to be set incorrectly, with the partition value becoming null.
Close #4044 .
Brief change log
How was this patch tested?
Add some test cases that check the changes thoroughly including negative and positive cases if possible
Add screenshots for manual tests if appropriate
Run test locally before making a pull request
Documentation
no
not documented