Repository navigation
fix: parse_url handles relative references like java.net.URI - #7392
Open
valentinsoe wants to merge 2 commits into
Open
valentinsoe wants to merge 2 commits into
valentinsoe wants to merge 2 commits into
Conversation
valentinsoe
force-pushed
the
fix/parse-url-relative-urls
branch
from
November 2, 2026 10:17
5e6ef04 to
1b6f970
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
valentinsoe
force-pushed
the
fix/parse-url-relative-urls
branch
from
November 2, 2026 10:19
1b6f970 to
778984c
Compare
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.
Which issue does this PR close?
Closes #7385.
Rationale for this change
Native
parse_url/try_parse_urlreturn NULL for every part of a URL without a scheme (/p?id=1,?id=7,//host/p,notaurl). Spark'sParseUrlusesjava.net.URI, which parses these as relative references, so with Comet enabledparse_url(page, 'QUERY', 'gclid')on logged page paths silently returns NULL instead of the value.What changes are included in this PR?
In
parse_url_component, the earlyreturn Ok(None)for scheme-less values is replaced by the two cases wherejava.net.URIactually rejects such a value::(empty scheme name, "Expected scheme name at index 0") →INVALID_URL;//,http://, "Expected authority") →INVALID_URL.Everything else goes through the existing
decompose_uri/ part extraction, which already splits relative references per RFC 3986 Appendix B.Side effects, both matching Spark:
://inside a relative URL's query (/r?to=http://x.com&id=1) no longer raisesINVALID_URL.http://(scheme, empty authority, nothing else) used to return PROTOCOLhttp; it now raisesINVALID_URL(ANSI) / returns NULL, as Spark does.Not in scope: Comet's character validation (
has_invalid_uri_chars) is narrower thanjava.net.URI's (e.g.|, a malformed%escape, a second#), andextract_hostdoesn't model registry-based authorities (//ex_ample.com/p). Those gaps already exist for absolute URLs and are tracked in #7330; with this change scheme-less inputs reach them too (Spark returns NULL for such inputs, Comet now returns parsed values instead of NULL).How are these changes tested?
parse_url.sql, plus relative and error cases inparse_url_ansi.sql.CometSqlFileTestSuite parse_urlpasses locally (Spark 4.1 profile) and fails onmainat the new queries.parse_url.rsfor the changed branch:test_relative_reference(a few relative references per part, expectations from Spark 4.1.1) andtest_invalid_relative_reference(:,:foo,://missing-scheme,//,http://). Both fail onmain; all existingspark-exprtests pass,cargo fmtandclippy -D warningsare clean.try_parse_url+java.net.URIvalidity on ~110k generated URLs and ~40k real-world relative page paths (each also tried with a host prepended): no change in results for absolute URLs except thehttp://-style inputs above; relative references now match Spark except the inputs covered by Native parse_url accepts URLs and registry-based hosts that java.net.URI treats differently #7330.cargo bench --bench parse_url(main vs this branch): existing absolute-URL cases unchanged (all within ±4%). Scheme-less rows now do the normal extraction instead of returning early.🤖 Generated with Claude Code