IO: Fix Windows drive letters misidentified as URI schemes - #3721
Open
qzyu999 wants to merge 1 commit into
Open
Conversation
On Windows, Python's urlparse treats paths like 'C:\Users\...' as having scheme='c', which causes 'Unrecognized filesystem type in URI: c' errors. This adds a platform-guarded predicate that detects single-character alphabetic schemes on Windows and remaps them to 'file', enabling correct local filesystem routing. Fixes all three parse sites (_infer_file_io_from_scheme, PyArrowFileIO.parse_location, FsspecFileIO._get_fs_from_uri) and includes platform-conditional tests. Related: apache#2477, apache#1005
This was referenced Jul 30, 2026
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
On Windows,
urlparse('C:\Users\...')producesscheme='c', causing:This breaks all local file operations for Windows users.
The Fix
A single platform-guarded predicate shared across all three affected parse sites:
When detected, the scheme is remapped to
'file', which routes to PyArrow/fsspec's local filesystem which already handles Windows paths natively.Changes
pyiceberg/io/__init__.py_infer_file_io_from_schemepyiceberg/io/pyarrow.pyparse_locationpyiceberg/io/fsspec.py_get_fs_from_uritests/io/test_io.pytests/io/test_pyarrow.pyparse_locationWindows testWhy all three sites?
They execute at different lifecycle stages and are reachable through independent code paths. Fixing only one (as PR #3161 did) leaves the others broken.
Regression safety
The
sys.platform == 'win32'guard means this is literally invisible on Linux/macOS the predicate short-circuits toFalsewithout inspecting the scheme. Existing CI onubuntu-latestcannot observe any change.Are these changes tested?
Yes. 11 new test cases covering:
@pytest.mark.skipifAll existing tests continue to pass.
Closes
Closes #3720
Related: #2477, #1005