Skip to content

Core: Enable picking of old partition spec data files using a flag for rewrite#16190

Open
mukund-thakur wants to merge 1 commit intoapache:mainfrom
mukund-thakur:core-rewrite-spec-mismatch-flag
Open

Core: Enable picking of old partition spec data files using a flag for rewrite#16190
mukund-thakur wants to merge 1 commit intoapache:mainfrom
mukund-thakur:core-rewrite-spec-mismatch-flag

Conversation

@mukund-thakur
Copy link
Copy Markdown
Contributor

@mukund-thakur mukund-thakur commented May 1, 2026

Fixes #16189

Explored solution using existing code and feature flags:

As our use case is to rewrite the old partition spec data files to new spec data files, we have to use rewrite-all=true as rewrite job will skip the files which are already of desired size for example (512 MB by default) or if only one file per group rewrite but we would still need to rewrite them to desired spec.
Based on a suggestion by @pvary on an old PR #here and looking at the current code, I thought we can use filters to filter only the old data files after applying rewrite-all=true based on some column values for example timestamp( month <=2025-06) for rewriting. To efficiently rewrite a huge number of data files we have to also use partial-progress.enabled and partial-progress.max-commits such that if job fails half way we don't need to start from scratch.

Why this won't work?

Suppose there are so many files to rewrite and jobs fail half way. When we rerun using the same filter, it will again pick up the same files even if we have rewritten suppose 50% of files successfully. We can somehow improve the filter to pick only old files after every iteration but it puts a lot of work on end-user as currently we can't filter data files based on the spec ID. That is why I suggest to enable this use case using this new flag ewrite-partition-spec-mismatch and partial-progress.enabled.

*
* <p>Defaults to false.
*/
public static final String REWRITE_PARTITION_SPEC_MISMATCH = "rewrite-partition-spec-mismatch";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this justifies adding another flag. You should be able to use existing flags to achieve this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking @nastra !
I went though the code but couldn't find any flag to achieve this.
We can use filters to filter old data based on some column values for example timestamp for rewriting first time but that won't work if there are so many files and jobs fail half way. When we rerun, it will again pick up the same files even if we have rewritten 50% of files successfully. Currently, we can't filter data files based on the spec ID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core: Enable re-partitioning of old spec data files.

2 participants