Skip to content

[Bug] parse_url raises on a malformed URL when ANSI mode is off, Spark returns NULL #26341

Open

Description

@comphead

Describe the bug

Spark's ParseUrl has failOnError = SQLConf.get.ansiEnabled (urlExpressions.scala#L211-L219). A malformed URL returns NULL unless ANSI mode is on, and then it raises INVALID_URL. try_parse_url never raises.

parse_url in datafusion-spark always raises the ANSI style error (parse_url.rs#L110-L113) and does not read datafusion.execution.enable_ansi_mode. With ANSI mode off, which is the DataFusion default, the result differs from Spark.

To Reproduce

Spark 4.0.0:

SELECT parse_url('inva lid://spark.apache.org/path?query=1', 'QUERY')
-- NULL                       (spark.sql.ansi.enabled=false)
-- [INVALID_URL] The url is invalid: inva lid://spark.apache.org/path?query=1.
-- Use `try_parse_url` to tolerate invalid URL and return NULL instead.   (spark.sql.ansi.enabled=true)

DataFusion: parse_url.slt#L346-L347 expects the error without enabling ANSI mode.

Expected behavior

Read enable_ansi_mode like the other ANSI aware functions in the crate (for example round): return NULL for a malformed URL when it is off and raise INVALID_URL when it is on. This is a small part of #23929.

Additional context

Found by running the queries in datafusion/sqllogictest/test_files/spark on a local Spark and comparing the results with the expected values in the files, which is the kind of check proposed in #17045. Spark results come from Apple's build of Spark 4.0.0 (4.0.0.65-apple) with a UTC session and spark.sql.ansi.enabled=false unless stated. The Spark source links point at the v4.0.0 tag. DataFusion results are the sqllogictest expectations at 9dec775, which CI enforces. Anything marked as not run was derived from reading the code.

Activity

  1. added
    bugSomething isn't working
    sparkChanges to datafusion-spark crate
    on Oct 14, 2026
  2. TechWizard9999 commented on Nov 5, 2026

    @TechWizard9999

    Hi @kosiew @comphead , I'd like to work on this. My plan is to read enable_ansi_mode in parse_url like round does return Null when off and update parse_url.slt.
    This is my appraoch in my mind !
    Please assign this issue to me
    Thanks!!

  3. kosiew commented on Nov 6, 2026

    @kosiew
    Contributor

    @TechWizard9999
    Assigned.

  4. TechWizard9999 commented on Nov 6, 2026

    @TechWizard9999

    Hi @kosiew @comphead , A small doubt like can I work on 2 issues at the same time as the review takes time right ?
    Please guide me through this
    Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingsparkChanges to datafusion-spark crate

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions