Skip to content

fix: accept single-slash local file URIs in Arrow FileIO - #1165

Open
XSY-28 wants to merge 2 commits into
apache:mainfrom
XSY-28:codex/fix-short-local-file-uri-341
Open

XSY-28 wants to merge 2 commits into
apache:mainfrom
XSY-28:codex/fix-short-local-file-uri-341

Conversation

@XSY-28

@XSY-28 XSY-28 commented Nov 23, 2026 •

Copy link
Copy Markdown

Fixes #341.

Java Iceberg writes absolute local URIs such as file:/warehouse/metadata/snap.avro. Arrow already parses this form, but the Iceberg FileIO wrapper passed it to Arrow's filesystem as a bare path. Route the one-slash form through the existing URI parser, normalizing its scheme while preserving the path.

The public FileIO test reads the same file through the one-slash, mixed-case, and three-slash forms and checks that a malformed short URI is rejected. This is the separate Arrow change requested in #818. Both new tests fail on the previous code. On macOS, the bundled Arrow suite passes 115 tests and the utility suite passes 431.

Generated by OpenAI Codex (GPT-6.2 Sol, xhigh) on behalf of @XSY-28. Human pre-submission review: unreviewed.

The author has now reviewed these changes.

Generated-by: OpenAI Codex (GPT-6.2 Sol, xhigh)
@zhjwpku

zhjwpku commented Nov 23, 2026

Copy link
Copy Markdown
Member

@XSY-28 Please review your own changes before opening a PR, your AI says these changes haven't been reviewed :-)

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall LGTM -- left two small comments on keeping single- and three-slash file: handling consistent and using our string helper instead of arrow::internal.

Comment thread src/iceberg/arrow/arrow_io.cc Outdated
if (pos == std::string::npos) {
return file_location;
const std::string_view uri(file_location);
if (::arrow::internal::AsciiEqualsCaseInsensitive(uri.substr(0, 6), "file:/") &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to my understanding, only the single-slash path normalizes the scheme to lowercase and fails immediately if PathFromUri errors, while file:///... still falls through to the fallback below. with MockFileSystem, wouldn't file:/tmp/x fail while file:///tmp/x returns /tmp/x? should both slash forms share the same scheme normalization and error handling, with mixed-case tests for both?

Comment thread src/iceberg/arrow/arrow_io.cc Outdated
if (pos == std::string::npos) {
return file_location;
const std::string_view uri(file_location);
if (::arrow::internal::AsciiEqualsCaseInsensitive(uri.substr(0, 6), "file:/") &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we use StringUtils::EqualsIgnoreCase from "iceberg/util/string_util.h" instead of pulling in arrow::internal (swapping out <arrow/util/string.h>)? keeping the substr(0, 6) boundary also avoids StartsWithIgnoreCase unicode folding changing byte lengths.

-  if (::arrow::internal::AsciiEqualsCaseInsensitive(uri.substr(0, 6), "file:/") &&
+  if (StringUtils::EqualsIgnoreCase(uri.substr(0, 6), "file:/") &&

Use the Iceberg string helper and report backend URI parser errors consistently for one- and three-slash local paths. Cover mixed-case URIs and backend rejection.

Prepared and tested with OpenAI Codex. Reviewed by the PR author before this update.

This branch has not been deployed

No deployments
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.

Failed to plan files: Invalid: Expected a local filesystem path, got a URI in PlanFiles() call in demo_example.cc

3 participants