TechWizard9999 opened a new issue, #409: URL: https://github.com/apache/datafusion-spark/issues/409
### Describe the bug With a third `key` argument, Spark's `parse_url` returns NULL unless the part is `QUERY`. datafusion-spark ignores the key for the other parts and returns the part itself. The key is only read in the two `QUERY` arms: [L87-L90](https://github.com/apache/datafusion-spark/blob/2129f388277144e4549654c8250a975ccf0322d4/crates/spark/src/function/url/parse_url.rs#L87-L90) for schemeless URLs and [L110-L113](https://github.com/apache/datafusion-spark/blob/2129f388277144e4549654c8250a975ccf0322d4/crates/spark/src/function/url/parse_url.rs#L110-L113) otherwise. The other arms return their part whatever the key is. `try_parse_url` does the same. ### To Reproduce ```sql SELECT parse_url('http://spark.apache.org/path?query=1', 'HOST', 'query'), parse_url('http://spark.apache.org/path?query=1', 'PATH', 'query'), parse_url('http://spark.apache.org/path?query=1', 'PROTOCOL', 'query'), parse_url('http://spark.apache.org/path?query=1', 'QUERY', 'query'); SELECT parse_url('/path?query=1', 'PATH', 'query'); SELECT try_parse_url('http://spark.apache.org/path?query=1', 'HOST', 'query'); ``` datafusion-spark returns: ``` spark.apache.org /path http 1 /path spark.apache.org ``` ### Expected behavior As in Spark: ``` NULL NULL NULL 1 NULL NULL ``` ### Spark versions Spark 4.0.0: `ParseUrlEvaluator.evaluate` with a key starts with `if (path != QUERY) return null` ([UrlExpressionEvalUtils.scala#L77](https://github.com/apache/spark/blob/v4.0.0/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/url/UrlExpressionEvalUtils.scala#L77)). Spark 3.5.0 has the same check ([urlExpressions.scala#L279](https://github.com/apache/spark/blob/v3.5.0/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/urlExpressions.scala#L279)). Spark 4.0's `try_parse_url` is `ParseUrl(children, failOnError = false)` ([urlExpressions.scala#L184](https://github.com/apache/spark/blob/v4.0.0/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/urlExpressions.scala#L184)), so the same check applies. Spark 3.5 has no `try_parse_url`. Not run on a live Spark. ### datafusion-spark version main at 2129f38 ### Additional context Open PR #390 moves this match into `extract_url_part`. Found with the sqllogictest runner, in both simplify and evaluate modes. cc @andygrove -- 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]
