Repository navigation
GH-27905: [Python][Dataset] Document dataset schema inference - #55942
Open
kukanggg89 wants to merge 1 commit into
Open
kukanggg89 wants to merge 1 commit into
kukanggg89 wants to merge 1 commit into
Conversation
Document that ds.dataset() infers the dataset schema from a single fragment only, so an all-null column in that fragment becomes null-typed for the whole dataset and scanning other files can fail with an ArrowTypeError. Adds a note to the schema parameter and a short example to the Dataset guide. Assisted-by: Muse
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
ds.dataset()infers the dataset schema from a single fragment when no schema is passed. A column that is all null in that fragment becomes null-typed for the whole dataset, and reading files where the column has values then fails with an ArrowTypeError. AlenkaF approved documenting this instead of changing the behavior in #27905.What changes are included in this PR?
schemaparameter ofdataset()now notes the schema is inferred from a single fragment only, and that passingschemaexplicitly avoids the null-column problem.Are these changes tested?
I did not run the test suite or the docs doctests here: this environment has no pyarrow install and the package needs the built C++ library. What I did check:
python -m py_compilepasses on the editeddataset.py, the example code parses, and the claims match the C++ source (InspectOptionsincpp/src/arrow/dataset/discovery.hdefaults to inspecting one fragment) and the repro in #27905. The guide example still needs the docs build in CI to confirm it runs.Are there any user-facing changes?
Yes. The
dataset()docstring and the Dataset guide now document the schema inference behavior and theschema=workaround. No code behavior changes.Was AI used for this PR?
Drafted with help from Claude. I reviewed and revised every change myself before opening this PR.
PR code and description written by:
Reviewed before submission by: