tlfua commented on code in PR #7456:
URL: https://github.com/apache/datafusion-comet/pull/7456#discussion_r4705361145
##########
native/spark-expr/src/conditional_funcs/case_when.rs:
##########
@@ -467,6 +476,26 @@ fn infallible(expr: &Arc<dyn PhysicalExpr>, input_schema:
&Schema, parsing: bool
} else {
cast.is_infallible(input_schema)
}
+ } else if let Some(check) = expr.downcast_ref::<CheckOverflow>() {
+ // Without `fail_on_error` a decimal that overflows the precision
becomes NULL
+ parsing
+ && !check.fail_on_error
+ && matches!(check.data_type, DataType::Decimal128(_, _))
+ && matches!(
+ check.child.data_type(input_schema),
+ Ok(DataType::Decimal128(_, _))
+ )
+ } else if let Some(function) = expr.downcast_ref::<ScalarFunctionExpr>() {
+ // Named as the planner names the functions it builds from Spark's, in
+ // `create_scalar_function_expr`
+ parsing && STRING_FUNCTIONS_THAT_CANNOT_FAIL.contains(&function.name())
Review Comment:
@rich7420 Thanks for catching this, and for measuring it. You're right.
`LazyLogical::wrap` and `lazy_in_list` share `cannot_fail` with
`NullShortCircuit`, so the cases I added in
d54d9a46971379517046848d99bee7b7b06569d9 also make AND, OR and IN evaluate
those right operands over the whole batch, which main does not do.
Here is what I'd like to do:
- Keep the check that `LazyLogical` and `lazy_in_list` use exactly as it is
on main.
- Move the new cases into a separate function that only `NullShortCircuit`
uses. Those cases are a `CheckOverflow` that does not fail, the narrow decimal
`+`, `-` and `*`, the string functions, and the widening casts.
- Add a test that `x AND substring(s, 2, 4) = '2345'` still builds a
`LazyLogical`.
With this, AND, OR and IN behave and perform as they do on main.
The two checks would then differ on purpose:
- For `NullShortCircuit`, the reviews asked to stop masking these operands,
and the benchmark shows that evaluating them over the whole batch costs no more
than eager.
- For AND and OR, main already evaluates them lazily, and your numbers show
that masking pays off there.
Does this direction work for you? cc @andygrove, since `LazyLogical` comes
from https://github.com/apache/datafusion-comet/pull/7326 .
--
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]