You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/04/07 11:00:42 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5906: add with_timezone

alamb commented on code in PR #5906:
URL: https://github.com/apache/arrow-datafusion/pull/5906#discussion_r1160626335


##########
datafusion/expr/src/function.rs:
##########
@@ -262,6 +262,25 @@ pub fn return_type(
 
         BuiltinScalarFunction::ArrowTypeof => Ok(DataType::Utf8),
 
+        BuiltinScalarFunction::WithTimezone => match input_expr_types[0] {
+            DataType::Timestamp(TimeUnit::Nanosecond, _) => {
+                Ok(DataType::Timestamp(TimeUnit::Nanosecond, None))
+            }
+            DataType::Timestamp(TimeUnit::Microsecond, _) => {
+                Ok(DataType::Timestamp(TimeUnit::Microsecond, None))
+            }
+            DataType::Timestamp(TimeUnit::Millisecond, _) => {
+                Ok(DataType::Timestamp(TimeUnit::Millisecond, None))
+            }
+            DataType::Timestamp(TimeUnit::Second, _) => {
+                Ok(DataType::Timestamp(TimeUnit::Second, None))
+            }
+            _ => return Err(DataFusionError::Internal(
+                "The with_timezone function can only accept timestamp as the first arg."
+                    .to_string(),
+            )),
+        },

Review Comment:
   I think you may need to special case it, in the same way as `arrow_cast`: https://github.com/apache/arrow-datafusion/blob/f00ef9d5484039dc7013af5b8fa04f7b29ffaba7/datafusion/sql/src/expr/function.rs#L139-L142
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org