Repository navigation
Core: Honor identity sort orders for Arrow table writes - #4449
Open
Anurag-S1ngh wants to merge 2 commits into
Open
Anurag-S1ngh wants to merge 2 commits into
Anurag-S1ngh wants to merge 2 commits into
Conversation
Sort materialized Arrow writes that use only identity sort fields with a consistent null order, and record the table's sort order id on the written data files. Each partition is sorted independently. Sort orders that cannot be applied, such as non-identity transforms, nested or missing sort columns, mixed null ordering, and streaming readers, leave the files marked unsorted and emit a warning.
write_file expects an Iterator, and mypy rejects a list on Python 3.11.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Arrow table writes ignored the table sort order and always wrote
sort_order_id=None, so manifests disagreed with the table metadata and readers could not prune on sort order.Sort materialized Arrow tables when every sort field uses an identity transform, the column exists at the top level, and all fields agree on null placement. Unpartitioned tables are sorted before bin packing and each partition is sorted on its own. The table sort order id is written on each data file.
Unsupported cases (non-identity transforms, nested or missing columns, mixed null placement, streaming
RecordBatchReaderwrites) keep writing unsorted files and emit a warning.Are these changes tested?
Yes. New tests in
tests/io/test_pyarrow.pycover the four direction and null-placement combinations, the unsupported cases, sorted files per partition, and the streaming warning.tests/tableand the local write tests pass.Are there any user-facing changes?
Yes. Tables with an identity sort order now write physically sorted data files that carry the sort order id. Previously written files are unchanged.