Skip to content

[python] [daft] Fix double-scheme prefix#7958

Merged
JingsongLi merged 4 commits into
apache:masterfrom
XiaoHongbo-Hope:daft_fix
May 26, 2026
Merged

[python] [daft] Fix double-scheme prefix#7958
JingsongLi merged 4 commits into
apache:masterfrom
XiaoHongbo-Hope:daft_fix

Conversation

@XiaoHongbo-Hope
Copy link
Copy Markdown
Contributor

@XiaoHongbo-Hope XiaoHongbo-Hope commented May 25, 2026

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

…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.
@XiaoHongbo-Hope XiaoHongbo-Hope marked this pull request as ready for review May 25, 2026 11:14
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.
@JingsongLi
Copy link
Copy Markdown
Contributor

+1

@JingsongLi JingsongLi merged commit d28705d into apache:master May 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants