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

[GitHub] [arrow-datafusion] viirya commented on a diff in pull request #6632: Fix date_trunc signature

viirya commented on code in PR #6632:
URL: https://github.com/apache/arrow-datafusion/pull/6632#discussion_r1225918413


##########
datafusion/expr/src/function.rs:
##########
@@ -221,17 +221,17 @@ pub fn return_type(
         BuiltinScalarFunction::Concat => Ok(Utf8),
         BuiltinScalarFunction::ConcatWithSeparator => Ok(Utf8),
         BuiltinScalarFunction::DatePart => Ok(Float64),
-        BuiltinScalarFunction::DateTrunc | BuiltinScalarFunction::DateBin => {
-            match input_expr_types[1] {
-                Timestamp(Nanosecond, _) | Utf8 => Ok(Timestamp(Nanosecond, None)),
-                Timestamp(Microsecond, _) => Ok(Timestamp(Microsecond, None)),
-                Timestamp(Millisecond, _) => Ok(Timestamp(Millisecond, None)),
-                Timestamp(Second, _) => Ok(Timestamp(Second, None)),
-                _ => Err(DataFusionError::Internal(format!(
-                    "The {fun} function can only accept timestamp as the second arg."
-                ))),
-            }
-        }
+        // DateTrunc always makes nanosecond timestamps
+        BuiltinScalarFunction::DateTrunc => Ok(Timestamp(Nanosecond, None)),

Review Comment:
   I guess that it is before because the second argument in `DateTrunc` signature is `Timestamp(Nanosecond, None)`. So it doesn't cause issue before?



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