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/01 11:07:53 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5818: feat: `date_trunc` return different types

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


##########
datafusion/physical-expr/src/datetime_expressions.rs:
##########
@@ -280,10 +280,25 @@ pub fn date_trunc(args: &[ColumnarValue]) -> Result<ColumnarValue> {
 
     Ok(match array {
         ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(v, tz_opt)) => {
-            ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(
-                (f)(*v)?,
-                tz_opt.clone(),
-            ))
+            let nano = (f)(*v)?;
+            match granularity.as_str() {
+                "minute" => {

Review Comment:
   I wondered if we needed to apply the same treatment to `microsecond` and `millisecond`, and it appears that those granularities are not supported:
   
   I https://github.com/apache/arrow-datafusion/blob/771c20ce2f0ade29a2d334e4e8494e9fbd7a5940/datafusion/physical-expr/src/datetime_expressions.rs#L218
   
   (I was wondering as there are both Microsecond and Millisecond Timestamps as well)
   https://github.com/apache/arrow-datafusion/blob/771c20ce2f0ade29a2d334e4e8494e9fbd7a5940/datafusion/common/src/scalar.rs#L116-L122



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