Repository navigation
fix(spark): return NULL from parse_url for a malformed URL unless ANSI - #26344
Open
ozenyunus35 wants to merge 1 commit into
Open
ozenyunus35 wants to merge 1 commit into
ozenyunus35 wants to merge 1 commit into
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?
Rationale for this change
In Spark,
parse_urlreturns NULL for a malformed URL unless ANSI mode is on, and only then raisesINVALID_URL. Thedatafusion-sparkversion always raised, and didn't look atdatafusion.execution.enable_ansi_mode, so with the default (ANSI off) a query that returns NULL in Spark failed here.What changes are included in this PR?
ParseUrl::invoke_with_argsreadsenable_ansi_modefrom the config, the same wayeltdoes.spark_parse_urlturns a parse error into NULL when ANSI mode is off, liketry_parse_urldoes; with ANSI mode on it keeps the current error. Argument count and type errors are not affected.What is the testing strategy for this PR?
parse_url.slt: the malformed URL case from the issue now returns NULL by default and still errors withenable_ansi_mode = true, and the same for a URL with an out-of-range port (InvalidPort). Without the change, the two NULL cases fail.test_malformed_url_is_null_unless_ansichecks both modes on a batch with a valid and a malformed URL.cargo test -p datafusion-spark --lib url::parse_url, thespark/urlsqllogictests andcargo clippy -p datafusion-spark --all-targets -- -D warningspass.Are there any user-facing changes?
Yes: with ANSI mode off (the default),
parse_urlreturns NULL for a malformed URL instead of an error, matching Spark.I used an AI assistant to help draft parts of the code and tests; I reviewed the changes and ran the tests myself.