Skip to content

fix(jdbc): skip slash-only prefixes in optimized overlap queries - #5029

Open
vigneshio wants to merge 5 commits into
apache:mainfrom
vigneshio:fix/jdbc-overlap-odd-root-prefixes
Open

fix(jdbc): skip slash-only prefixes in optimized overlap queries#5029
vigneshio wants to merge 5 commits into
apache:mainfrom
vigneshio:fix/jdbc-overlap-odd-root-prefixes

Conversation

@vigneshio

Copy link
Copy Markdown
Contributor

Fixes #5023.

Follow-up from the side note on #5003.

When building JDBC optimized location-overlap queries, scheme stripping turns paths like s3://bucket/tmp/location into //bucket/tmp/location. The prefix walk then emitted slash-only terms (/, //) that are not real storage locations.

@dimas-b dimas-b 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.

LGTM overall with minor comments 👍

Comment thread CHANGELOG.md Outdated
@dimas-b
dimas-b requested a review from adutra August 14, 2026 16:03
@vigneshio
vigneshio force-pushed the fix/jdbc-overlap-odd-root-prefixes branch 2 times, most recently from f1efcb6 to ee55051 Compare August 18, 2026 13:22
@vigneshio
vigneshio requested a review from dimas-b August 19, 2026 10:58

@flyingImer flyingImer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One blocking concern remains around the slash-only prefix filtering: it can hide an existing custom-location ancestor from the overlap check, as detailed inline. Once addressed, this only needs a rebase for the CHANGELOG conflict and fresh CI.

Comment on lines 437 to 443
// Skip "/" and "//" produced from empty path segments around the scheme separator; those
// are not meaningful storage locations. "///" (the root of file: URIs) is kept.
if (prefix.length() < 3 && isSlashOnly(prefix)) {
continue;
}
conditions.add("location_without_scheme = ?");
parameters.add(prefix);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

IIRC, Polaris still supports custom namespace locations outside the parent hierarchy through the ALLOW_NAMESPACE_CUSTOM_LOCATION compatibility flag. In that mode, s3:// is accepted and persisted as // in location_without_scheme, while S3Location treats s3://bucket/path as its child. Dropping // here means JDBC never loads that ancestor, so isChildOf cannot reject the overlap. Could we either retain this term and add a relational test for this pair, or reject scheme-root locations and handle existing rows before pruning it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Kept // and added the relational coverage.

The skip now drops only /. We retain // and /// since // can represent a valid namespace at the s3:// root in ALLOW_NAMESPACE_CUSTOM_LOCATION mode.

Added a test to ensure s3://bucket/ns/t still matches an ancestor at //. PTAL.

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.

Using s3:// as a location would be really awkward, but it's fine to support it for backward compatibility with old Polaris versions.

Scheme stripping turns s3://bucket/path into //bucket/path, so the
prefix walk previously emitted / and // equality terms that are not
real storage locations. Skip slash-only prefixes when building the
overlap query. Same for file:/// paths that produced /// alone.

Fixes apache#5023
@vigneshio
vigneshio force-pushed the fix/jdbc-overlap-odd-root-prefixes branch from ee55051 to 260d923 Compare September 3, 2026 09:23
@vigneshio
vigneshio requested a review from flyingImer September 3, 2026 09:25
@vigneshio
vigneshio requested a review from dimas-b September 4, 2026 19:05
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.

Odd / and // paths in JDBC optimized location overlap checks

3 participants