[python] [daft] Fix double-scheme prefix#7958
Merged
Merged
Conversation
…ile_uri
REST catalogs (e.g. DLF) return absolute paths in DataFileMeta.file_path
(typically oss:// or s3://). The previous unconditional
f"{self._warehouse_scheme}://{file_path}"
produced invalid URIs such as "file://oss://bucket/..." when the warehouse
itself has no scheme (REST catalog name like "morax_test"), breaking Daft's
URL parser and crashing the read pipeline.
Fix: if file_path already starts with a known absolute URI scheme
(oss://, s3://, s3a://, s3n://, hdfs://, file://, http://, https://),
return it unchanged.
This bug was not caught by existing tests because all daft fixtures use a
local tmp_path warehouse, where file_path comes back without a scheme and
the prefix logic happens to work.
Added paimon-python/pypaimon/tests/daft/daft_datasource_test.py covering
scheme pass-through for each backend plus the DLF-style regression case.
Address review feedback: drop the explanatory comment block above _ABSOLUTE_URI_SCHEMES and shrink the _build_file_uri docstring back to a one-liner. The constant name and the new test file already convey the intent. Also strip the redundant class docstring and inline comments from the new BuildFileUriTest cases.
Replace the hardcoded scheme list with urlparse(file_path).scheme. The previous tuple (oss/s3/s3a/s3n/hdfs/file/http/https) misses schemes that Paimon also supports (gs://, abfs://, dbfs://, viewfs://, swift://, ...) and is brittle to extend. urlparse handles any RFC-3986 scheme without maintenance and is already imported in this module. Tests unchanged; same 3 tests + 8 subtests pass.
Aligns with the existing pattern in daft_catalog_test, daft_data_test, daft_sink_test, and daft_catalog_rest_test. Without this guard, collection fails with ImportError in environments where daft is not installed instead of skipping cleanly.
Contributor
|
+1 |
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.
Purpose
When running a Daft read_paimon(...) against a Paimon table managed by Paimon REST catalog backed by OSS, the read crashes immediately:
daft.exceptions.DaftCoreException: DaftError::External Unable to convert URL
"file://oss://my_bucket/my_db.db/my_tablebucket-0/data-0d475e4b-c35b-4afa-a5d9-a467cc008462-0.parquet"
to path
Note the file://oss://... — double scheme. Daft's URL parser can't make sense of it. This PR fixes the above issue
Tests
daft_datasource_test