Repository navigation
Conversation
Add LocationUtil::HasScheme, ResolveLocation and RelativizeLocation for v4 relative paths, as defined in the spec's "Paths in Metadata" section. - HasScheme is strict RFC 3986 scheme detection on every platform. - ResolveLocation returns absolute paths unchanged and joins relative paths to the table location with "/", with no normalization or URI parsing. If the table location already ends in "/", no second separator is added, since object stores such as S3 treat "//" as part of the key. - RelativizeLocation strips the table location and one separator when a path is under it, and otherwise returns the path unchanged. Tests cover every example in the spec's path resolution table, plus trailing slashes, sibling prefixes, schemes, escaped characters and round trips. Closes apache#1123
xndai
force-pushed
the
xndai/iceberg-cpp/R1
branch
from
November 14, 2026 18:18
c6a7e77 to
4d2ac7a
Compare
This branch has not been deployed
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.
Closes #1123.
What
Adds three helpers to
LocationUtil(src/iceberg/util/location_util.{h,cc}) for v4 relative paths, as defined in the spec's Paths in Metadata section (apache/iceberg#15630):HasScheme(location): true when the text before the first:is a non-empty RFC 3986 scheme.ResolveLocation(table_location, location) -> std::string: absolute paths are returned unchanged; relative paths becometable_location + "/" + location.RelativizeLocation(table_location, location) -> std::string_view: whenlocationstarts withtable_locationimmediately followed by/, returns the rest after that separator; otherwise returnslocationunchanged.Nothing calls them yet. Using them in metadata, manifests and catalogs is left to follow-up PRs.
Trailing separator on the table location
The spec recommends that a table location not end in
/, because the join would otherwise produce//(its "Duplicate separator" example). This PR applies that recommendation more strongly: when the table location ends in/,ResolveLocationdoesn't add a second separator (s3://bucket/db/table/+data/00000-0.parquet→s3://bucket/db/table/data/00000-0.parquet). Object stores such as S3 treat//as part of the key and advise against it.Comparison with Java
Matches Java's
LocationUtil.hasScheme/resolveLocation/relativizeLocation(apache/iceberg#16174, apache/iceberg#17807), with these differences:/; this PR handles the trailing/as described above.RelativizeLocationreturns astd::string_viewinto itslocationargument, because the result is always a suffix of that argument and copying it isn't needed.Edge cases that match Java: only one separator is stripped, so
<loc>//xrelativizes to/xand resolves back to<loc>//x, and the table location itself is kept absolute.Not covered: adding a scheme to pre-v4 paths
The spec's Path Resolution section ends with a table of examples. Its last row, "Missing scheme", is about v3 and earlier tables: a stored path without a scheme, such as
/wh/db/table/data/00000-0.parquet, should get one added (hdfs://wh/db/table/data/00000-0.parquetin the example). That path is already complete, so this isn't relative resolution, and the spec doesn't say where the scheme comes from. This PR doesn't do it; that is follow-up work. For that row, the test only checks that such a path isn't treated as absolute (HasSchemeis false). The other rows are tested throughResolveLocation.Tests
src/iceberg/test/location_util_test.cc:HasSchemegrammar cases: leading digit or+,_,/before the colon, empty input, the Windows extended-length form, drive letters../.., plus both kinds of duplicate separator./tvs/t2), the table location itself, different and case-differing schemes, trailing slashes./on the table location.icb build -j 12, the fullicb test -j 12(21/21) andicb precommitall pass.