kosiew commented on code in PR #18191:
URL: https://github.com/apache/datafusion/pull/18191#discussion_r2454299967
##########
datafusion/functions/src/core/nvl2.rs:
##########
@@ -95,8 +96,71 @@ impl ScalarUDFImpl for NVL2Func {
Ok(arg_types[1].clone())
}
+ fn return_field_from_args(&self, args: ReturnFieldArgs) ->
Result<FieldRef> {
+ let nullable =
+ args.arg_fields[1].is_nullable() ||
args.arg_fields[2].is_nullable();
+ let return_type = args.arg_fields[1].data_type().clone();
+ Ok(Field::new(self.name(), return_type, nullable).into())
+ }
+
fn invoke_with_args(&self, args: ScalarFunctionArgs) ->
Result<ColumnarValue> {
- nvl2_func(&args.args)
+ let [test, if_non_null, if_null] = take_function_args(self.name(),
args.args)?;
Review Comment:
> In https://github.com/apache/datafusion/pull/17357 the author chose to
make invoke_with_args return an internal error instead of retaining the
implementation. Would we want to do the same here?
I amended invoke_with_args to return internal_err for consistency and also
to reduce 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]