mbutrovich opened a new issue, #7669:
URL: https://github.com/apache/datafusion-comet/issues/7669

   ### What is the problem the feature request solves?
   
   `create_scalar_function_expr` builds every `ScalarFunctionExpr` with 
[`ConfigOptions::default()`](https://github.com/apache/datafusion-comet/blob/ba16e1a53127c90ba00fdc7058703945a8bb9f34/native/core/src/execution/planner.rs#L2260-L2266).
 The datafusion-spark functions read ANSI mode from 
`config_options.execution.enable_ansi_mode` at execution time, for example 
[`abs`](https://github.com/apache/datafusion-spark/blob/125600164aa825e2fe805887dfdb384d4182f2a8/crates/spark/src/function/math/abs.rs#L97)
 and 
[`next_day`](https://github.com/apache/datafusion-spark/blob/125600164aa825e2fe805887dfdb384d4182f2a8/crates/spark/src/function/datetime/next_day.rs#L114).
 Under Comet they always see `false`, so they return NULL or a wrapped value 
where Spark with ANSI mode on raises an error.
   
   Comet's own functions don't have this problem, because the planner passes 
[`expr.fail_on_error`](https://github.com/apache/datafusion-comet/blob/ba16e1a53127c90ba00fdc7058703945a8bb9f34/native/core/src/execution/planner.rs#L2234-L2239)
 to their constructors. The "Port ... from Comet" issues in datafusion-spark 
plan for Comet to use the datafusion-spark versions and remove its copies (for 
example apache/datafusion-spark#125). apache/datafusion-spark#329 ports 
`make_date` and reads the session config in place of Comet's `fail_on_error` 
constructor argument. Each such switch turns Comet's ANSI errors for that 
function into NULLs.
   
   ### Describe the potential solution
   
   In `create_scalar_function_expr`, pass a `ConfigOptions` with 
`execution.enable_ansi_mode` set to 
[`expr.fail_on_error`](https://github.com/apache/datafusion-comet/blob/ba16e1a53127c90ba00fdc7058703945a8bb9f34/native/proto/src/proto/expr.proto#L597-L601)
 instead of the default. Two shared `Arc<ConfigOptions>` values, one per mode, 
avoid an allocation per expression.
   
   The same `ConfigOptions` can carry the datafusion-spark config extension 
that apache/datafusion-spark#92 proposes. That issue notes that Comet sees only 
the defaults, and concludes that every flag also needs a constructor argument 
or a public function. If Comet populates `ConfigOptions` itself, the flags that 
are read at execution time wouldn't need that second way in.
   
   ### Additional context
   
   Spark's `try_*` functions are a third mode (`EvalMode::Try`). A single 
`bool` can't express it, so this change covers ANSI and legacy only.
   


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