-
Notifications
You must be signed in to change notification settings - Fork 1k
Implement a Vec<RecordBatch> wrapper for pyarrow.Table convenience
#8790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jonded94
wants to merge
10
commits into
apache:main
Choose a base branch
from
jonded94:implement-pyarrow-table-convenience-class
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+264
−32
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4b4f071
Implement a `Vec<RecordBatch>` wrapper for `pyarrow.Table` convenience
jonded94 4d9e9cf
Solve review remarks; current status still broken
jonded94 36bcc84
Use `pyo3_arrow`'s `schema_equals` function for now
jonded94 12b4236
Fix typo
jonded94 bf20c77
Add typehints & add required `requested_schema` parameter to the PyCa…
jonded94 52047b8
Fall back to `pyarrow.Table.to_batches()` method since it preserves m…
jonded94 9a9cd9f
Add docs
jonded94 20e0849
Fix Python backwards compatibility
jonded94 1898a03
Let `ArrowArrayStreamReader` actually preserve metadata
jonded94 b61aae0
Augment tests to also check for metadata
jonded94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please leave a comment here explaining:
SAFETYcomment explaining why theunsafeis ok (aka how the invariants required for RecordBatch::new_unchecked are satisfied)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically what I explained here (#8790 (comment)) =>
StructArrayalone by definition is metadata-less, in turn leading to the problem that the resultingRecordBatchwon't have any metadata attached if you just return it as-is.I'm not sure whether there is another more elegant way to construct a
RecordBatchwith corresponding metadata fromArrayData. Right now I'm going throughStructArraybecause the previous interface did that too. If there is another more elegant way, please let me know.Other ways to attach metadata to an existing
RecordBatchwould be, as far as I can see, to callwith_schema()(which will incure some "is subschema test" costs) or somehow throughschema_metadata_mut(), but the interface feels a bit clunky for this specific task IMHO.One reason for the
unsafehere is that I did not want to introduce performance penalties in comparison to what the interface did before (it just returnedRecordBatchwithout checking whether it's actually corresponding to the schema ofArrowArrayStreamReader; and the schemas actually mismatched before my change, at least metadata-wise).In principle
IteratorofArrowArrayStreamReaderreturnsResult, so we can make this fallible throughRecordBatch::try_new(...). This would incur some costs though, such as checking each column for correct nullability, equal and correct row count, type checks, etc..I would have guessed that at least data-wise the interface can be trusted and therefore the checks can be omitted? 😅 I'm really not the expert here, I would have assumed that someone from the
arrow-rsteam could have some opinion here 😬