Repository navigation
fix: breaking change in pl.from_arrow in polars 2.x - #187
Merged
Merged
Conversation
Oxbow readers are implemented using pyo3-arrow. In Python, the reader batches are returned as arro3.core.RecordBatch objects, which are not recognized as pyarrow objects for pl.from_arrow. In polars 1.x, arro3 batches where converted to dataframes with a warning. In polars 2.x, arro3 batches are converted to a struct of series, which is a different type and causes a raise. Fixed by explicit casting to DataFrame, which does not cause performance degradation and is backwards compatible.
The test used pyarrow batches, which polars 2.x treats slightly differently than the arro3 ones (which are the ones that the built-in readers from oxbow actually return). Without this change, tests could false negative errors due to changes in polars 2.x.
Without updating uv lock, only versions 1.x of polars would be tested, causing issues with 2.x to be missed.
Addressed same bug in the example code, by casting to DataFrame instead. Also, fixed misleading dtype declaration in docs. Note: polars 2.x changes default rendering of lf.show_graph(). As no text in the documentation refers to its content, accepted the change silently.
Several packages do not have wheels for 3.14 at the moment, which would require major changes to the lock file. Trying by temporarily pinning to an older version instead.
This was referenced Nov 17, 2026
Member
|
Thank you, @StefanoCretti! |
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.
In polars 1.x, calling
pl.from_arrowon an arro3RecordBatchobject yields aDataFrame.In polars 2.x, the same call returns a struct of
Series.This caused any reader yielding a
LazyFrameto raise.Fixed by explicit
DataFramecasting instead offrom_arrow(also works in 1.x).Also fixed same pattern in documentation code snippet and its description.
Updated test suite to test against polars 2.x (before only 1.x).
Fixes #186