jayzhan211 commented on code in PR #12308:
URL: https://github.com/apache/datafusion/pull/12308#discussion_r1752083302


##########
datafusion/functions/src/datetime/to_local_time.rs:
##########
@@ -348,6 +327,25 @@ impl ScalarUDFImpl for ToLocalTimeFunc {
 
         self.to_local_time(args)
     }
+
+    fn coerce_types(&self, arg_types: &[DataType]) -> Result<Vec<DataType>> {
+        if arg_types.len() != 1 {
+            return Err(DataFusionError::Execution(format!(
+                "to_local_time function requires 1 argument, got {:?}",
+                arg_types.len()
+            )));
+        }
+
+        match &arg_types[0] {
+            Timestamp(Nanosecond, timezone) => Ok(vec![Timestamp(Nanosecond, 
timezone.clone())]),
+            Timestamp(Microsecond, timezone) => Ok(vec![Timestamp(Microsecond, 
timezone.clone())]),
+            Timestamp(Millisecond, timezone) => Ok(vec![Timestamp(Millisecond, 
timezone.clone())]),
+            Timestamp(Second, timezone) => Ok(vec![Timestamp(Second, 
timezone.clone())]),
+            _ => Err(DataFusionError::Execution(format!(

Review Comment:
   You could try to rewrite the error with `The to_local_time function can only 
accept timestamp as the arg. got Utf8`.



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