andygrove opened a new pull request, #89:
URL: https://github.com/apache/datafusion-spark/pull/89

   ## Which issue does this PR close?
   
   Part of #88, which needs an eval mode for the Spark-compatible `CAST` port.
   
   ## Rationale for this change
   
   Functions that behave differently with ANSI mode on read `enable_ansi_mode` 
and pass a `bool` down. Spark's `try_*` functions are a third mode: the same as 
ANSI, except that an error on a value produces `NULL`. `try_parse_url` gets 
that mode by passing its own error handler to `spark_handled_parse_url`. Spark 
models all three as 
[`EvalMode`](https://github.com/apache/spark/blob/v4.1.1/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EvalMode.scala).
 Comet does the same, and its `CAST` takes an `EvalMode`, so porting it needs 
this type.
   
   ## What changes are included in this PR?
   
   - A public `datafusion_spark::EvalMode { Legacy, Ansi, Try }`, with 
`EvalMode::from_config(&ConfigOptions)` and 
`EvalMode::from_ansi_enabled(bool)`, matching Spark's `fromSQLConf` and 
`fromBoolean`. The default is `Legacy`, as with `enable_ansi_mode`.
   - `parse_url` and `try_parse_url` share a new public `spark_parse_url(args, 
EvalMode)` that returns `NULL` for a malformed URL in `Legacy` and `Try`, and 
an error in `Ansi`. The private `spark_try_parse_url` is removed.
   
   `spark_handled_parse_url` is unchanged. The other functions that read 
`enable_ansi_mode` (`abs`, `mod`, `pmod`, `negative`, `round`, `elt` and 
`spark_cast`) are not changed here, because some of them have public functions 
that take a `bool`. They can move to `EvalMode` separately.
   
   ## Are these changes tested?
   
   Unit tests cover the `EvalMode` constructors and `spark_parse_url` in all 
three modes. The existing `parse_url.slt` already covers `parse_url` with ANSI 
on and off, and `try_parse_url` returning `NULL` with ANSI on.
   
   ## Are there any user-facing changes?
   
   There are two new public items, `EvalMode` and `spark_parse_url`. No 
behavior changes.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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