ump45nose opened a new pull request, #26919:
URL: https://github.com/apache/datafusion/pull/26919
## Which issue does this PR close?
- Closes #26341
## Rationale for this change
Spark's `parse_url` treats a malformed URL as an error only when ANSI mode
is enabled (`failOnError`). With ANSI off (DataFusion's default), Spark
returns NULL instead. Our `parse_url` always raised, so queries that Spark
would tolerate failed here. `try_parse_url` already maps parse failures to
NULL; `parse_url` should do the same whenever ANSI is off.
## What changes are included in this PR?
- `ParseUrl::invoke_with_args` reads `enable_ansi_mode` (same pattern as
`elt` / `round`) and passes it into `spark_parse_url`.
- When ANSI is off, parse errors become NULL; when on, they still error.
Wrong arity / non-string args still error either way.
- Unit test for the ANSI/non-ANSI paths, plus sqllogictest coverage for a
space-in-scheme URL and an out-of-range port.
## What is the testing strategy for this PR?
- Unit: `cargo test -p datafusion-spark --lib function::url::parse_url`
- SQL: `cargo test -p datafusion-sqllogictest --test sqllogictests --
spark/url/parse_url`
## Are there any user-facing changes?
Yes — with the default (`enable_ansi_mode = false`), `parse_url` on a
malformed URL now returns NULL instead of an Execution error. Callers that
need the strict behavior can set `datafusion.execution.enable_ansi_mode =
true`
or use `try_parse_url` when they always want NULL.
## AI assistance
Used AI tooling to locate the bug against Spark semantics and draft the
change; I reviewed the patch, ran the tests above, and wrote this
description.
--
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]