harshchawra commented on code in PR #19340:
URL: https://github.com/apache/datafusion/pull/19340#discussion_r2623450857
##########
datafusion/spark/src/function/datetime/next_day.rs:
##########
@@ -63,7 +64,27 @@ impl ScalarUDFImpl for SparkNextDay {
}
fn return_type(&self, _arg_types: &[DataType]) -> Result<DataType> {
- Ok(DataType::Date32)
+ internal_err!("return_field_from_args should be used instead")
+ }
+
+ fn return_field_from_args(&self, args: ReturnFieldArgs) ->
Result<FieldRef> {
+ let [date_field, weekday_field] = args.arg_fields else {
+ return internal_err!("Spark `next_day` expects exactly two
arguments");
+ };
+
+ let nullable =
+ date_field.is_nullable()
+ || weekday_field.is_nullable()
+ || args
+ .scalar_arguments
+ .iter()
+ .any(|arg| matches!(arg, Some(v) if v.is_null()));
Review Comment:
Thanks for the review.
You’re right that `next_day` can also return `NULL` for invalid non-NULL
scalar values.
I’ll update `return_field_from_args` to treat invalid scalar arguments as
nullable.
Will push an update shortly.
--
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]