feat: make parse_url compatible#4413
Draft
parthchandra wants to merge 1 commit into
Draft
Conversation
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 #4150.
Rationale for this change
PR #4350 wired
parse_urlthrough Comet's serde layer to the upstreamdatafusion-sparkUDFs but marked itIncompatibledue to divergences between the WHATWG URL Standard (urlcrate) and Spark'sjava.net.URI(RFC 3986). This PR replaces the upstream implementation with a local RFC 3986 regex-basedparser that matches Spark's behavior, promoting
parse_urlfromIncompatibletoCompatible.What changes are included in this PR?
New:
native/spark-expr/src/url_funcs/parse_url.rsCometParseUrlandCometTryParseUrlUDFs using RFC 3986 Appendix B regex decomposition instead of the WHATWGurlcrate""(was NULL)http://host?foo=bar) returns?foo=bar(was/?foo=bar)http://host/) returns"/"(was"")=(e.g.,?a=b=c) now correctly returnb=cparse_url(url, 'HOST', 'key')) returns NULLhttp://host:/path) strips trailing colonhttp:///path) returns NULL instead of""[INVALID_URL]error for malformed URLs (spaces, control chars, missing scheme with://)Modified:
native/core/src/execution/jni_api.rsCometParseUrl/CometTryParseUrlfromspark-exprinstead of upstreamSparkParseUrl/SparkTryParseUrlModified:
spark/.../serde/url.scalaIncompatibleoverride andincompatibleReason(nowCompatibleby default)Modified: SQL test files
parse_url.sql: expanded from 4 fallback queries to 30+ native-execution queries covering all components, edge cases, and divergence fixesparse_url_ansi.sql: enables previously-ignored ANSI error tests withexpect_error(INVALID_URL)How are these changes tested?
parse_url.rscovering all URL components, divergence fixes, error handling, null propagation, and edge cases (query values with=, 3-arg non-QUERY, empty port, empty authority, IPv6, malformed URLs)parse_url.sql,parse_url_ansi.sql) verified against Spark on bothspark-4.0andspark-4.1profiles