CuteChuanChuan commented on code in PR #26498:
URL: https://github.com/apache/datafusion/pull/26498#discussion_r4316365751
##########
datafusion/functions/src/core/nvl2.rs:
##########
@@ -125,20 +125,11 @@ impl ScalarUDFImpl for NVL2Func {
fn coerce_types(&self, arg_types: &[DataType]) -> Result<Vec<DataType>> {
let [tested, if_non_null, if_null] = take_function_args(self.name(),
arg_types)?;
- let new_type =
- [if_non_null, if_null]
- .iter()
- .try_fold(tested.clone(), |acc, x| {
- // `type_union_coercion` finds a loose common type; the
actual
- // coercion is done by `maybe_data_types`.
- let coerced_type = type_union_coercion(&acc, x);
- if let Some(coerced_type) = coerced_type {
- Ok(coerced_type)
- } else {
- internal_err!("Coercion from {acc} to {x} failed.")
- }
- })?;
- Ok(vec![new_type; arg_types.len()])
+ let Some(new_type) = type_union_coercion(if_non_null, if_null) else {
Review Comment:
Good catch, thanks! Swapped the arguments to match CASE's ELSE-first order
and added your timezone example as a test. Addressed in
[0ab9bac](https://github.com/apache/datafusion/pull/26498/commits/0ab9bac555d6b2a5aa567bbc37c01b163ccb3f17)
--
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]