ozenyunus35 opened a new pull request, #26344:
URL: https://github.com/apache/datafusion/pull/26344

   ## Which issue does this PR close?
   
   - Closes #26341.
   
   ## Rationale for this change
   
   In Spark, `parse_url` returns NULL for a malformed URL unless ANSI mode is 
on, and only then raises `INVALID_URL`. The `datafusion-spark` version always 
raised, and didn't look at `datafusion.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_args` reads `enable_ansi_mode` from the config, the 
same way `elt` does.
   - `spark_parse_url` turns a parse error into NULL when ANSI mode is off, 
like `try_parse_url` does; 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 with `enable_ansi_mode = true`, and the same for a URL 
with an out-of-range port (`InvalidPort`). Without the change, the two NULL 
cases fail.
   - New unit test `test_malformed_url_is_null_unless_ansi` checks both modes 
on a batch with a valid and a malformed URL.
   - `cargo test -p datafusion-spark --lib url::parse_url`, the `spark/url` 
sqllogictests and `cargo clippy -p datafusion-spark --all-targets -- -D 
warnings` pass.
   
   ## Are there any user-facing changes?
   
   Yes: with ANSI mode off (the default), `parse_url` returns 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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to