Repository navigation
GH-53033: [Python][Dataset] Support mixed FileInfo and path sources without crashing - #53034
Open
Mohit-25-tech wants to merge 1 commit into
Open
Mohit-25-tech wants to merge 1 commit into
Mohit-25-tech wants to merge 1 commit into
Conversation
|
|
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.
What changes are included in this PR?
Fixes #53033
This PR fixes a bug in
pyarrow.dataset.dataset()where mixingFileInfoobjects and path-like sources produces inconsistent behavior depending on their order.Previously:
[path, path]— works.[FileInfo, FileInfo]— works.[path, FileInfo]— raisesTypeError.[FileInfo, path]— causes a native segmentation fault.The issue occurs because the dataset construction logic determines how to process the entire source list based on its first element, even when subsequent elements have different types.
Root cause
The public
dataset()API accepts lists containing path-like objects orFileInfoobjects.However,
_filesystem_dataset()previously dispatched based on the first element alone.When the first element was
FileInfo, the mixed list could reachFileSystemDatasetFactory, where the Cythonunwrap_finfos()implementation performed an unchecked cast of subsequent elements toFileInfo.This could terminate the Python interpreter instead of raising a normal exception.
Changes
1. Support mixed sources in the Python wrapper
FileInfoobjects using the selected filesystem.FileInfoobjects and their metadata.FileInfolists on their existing processing paths.2. Add defensive Cython validation
FileInfo.TypeErrorfor unsupported mixed inputs passed directly to the native factory.3. Add regression tests
Add coverage for:
FileInfocombinations.FileInfoobjects.FileSystemDatasetFactoryinvalid-input handling.Behavior after the fix
For valid files, all four input combinations are supported:
Each should construct a dataset successfully without losing source ordering or duplicate entries.
Invalid or missing paths continue to raise appropriate Python exceptions rather than being silently ignored.
Testing
Independent reproduction
[FileInfo, path]terminates the original process withSIGSEGV(exit code-11).Patched implementation verification
dataset.pywrapper with the installed PyArrow 26.0.0 native runtime in Kaggle.git diff --checkpassed.Testing limitations
The combined Python and Cython changes require repository CI validation.
Compatibility and performance considerations
The change extends the public dataset API to support mixed path and
FileInfolists.Existing homogeneous-source behavior is preserved.
For mixed lists, resolving path entries to
FileInfoobjects can introduce an additional filesystem metadata lookup, including on remote filesystems.AI assistance
OpenAI Codex assisted with investigating the issue, implementing the changes, creating regression tests, and reviewing the patch.
I independently reproduced the original crash, tested the modified Python implementation using Kaggle, and reviewed the proposed behavior and verification results.
Related issue
Fixes #53033