martin-g commented on code in PR #19340:
URL: https://github.com/apache/datafusion/pull/19340#discussion_r2623473194


##########
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:
   You could also see whether 
https://doc.rust-lang.org/std/primitive.str.html#method.eq_ignore_ascii_case 
could be used.
   If there is no hard reason to trim the scalar value then using 
eq_ignore_ascii_case() could save some allocations by .to_uppercase().



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