waitingkuo commented on PR #6632:
URL: 
https://github.com/apache/arrow-datafusion/pull/6632#issuecomment-1586877278

   hi @alamb thank you for pining me
   
   
https://github.com/apache/arrow-datafusion/blob/373e291faba5b3c722018367e01a6b59a91bddee/datafusion/physical-expr/src/datetime_expressions.rs#L286-L317
   
   for angularity minute, second, and millisecond, it returns second, 
millisecond, and microsecond
   
   ```bash
   ❯ select arrow_typeof(date_trunc('minute', 
'2001-01-01T00:00:00.123456789'::timestamp));
   
+--------------------------------------------------------------------------------+
   | 
arrow_typeof(date_trunc(Utf8("minute"),Utf8("2001-01-01T00:00:00.123456789"))) |
   
+--------------------------------------------------------------------------------+
   | Timestamp(Second, None)                                                    
    |
   
+--------------------------------------------------------------------------------+
   1 row in set. Query took 0.003 seconds.
   ```
   
   ```bash
   ❯ select arrow_typeof(date_trunc('second', 
'2001-01-01T00:00:00.123456789'::timestamp));
   
+--------------------------------------------------------------------------------+
   | 
arrow_typeof(date_trunc(Utf8("second"),Utf8("2001-01-01T00:00:00.123456789"))) |
   
+--------------------------------------------------------------------------------+
   | Timestamp(Millisecond, None)                                               
    |
   
+--------------------------------------------------------------------------------+
   1 row in set. Query took 0.003 seconds.
   ```
   
   ```bash
   ❯ select arrow_typeof(date_trunc('millisecond', 
'2001-01-01T00:00:00.123456789'::timestamp));
   
+-------------------------------------------------------------------------------------+
   | 
arrow_typeof(date_trunc(Utf8("millisecond"),Utf8("2001-01-01T00:00:00.123456789")))
 |
   
+-------------------------------------------------------------------------------------+
   | Timestamp(Microsecond, None)                                               
         |
   
+-------------------------------------------------------------------------------------+
   1 row in set. Query took 0.003 seconds.
   ```
   
   for the array implementation it returns error since
   
   ```bash
   ❯ select date_trunc('minute', a) from (select 
'2001-01-01T00:00:00'::timestamp as a) union (select '2001-01-01T00:00:01');
   External error: Arrow error: Invalid argument error: RowConverter column 
schema mismatch, expected Timestamp(Second, None) got Timestamp(Nanosecond, 
None)
   ```
   
   ```bash
   ❯ select date_trunc('second', a) from (select 
'2001-01-01T00:00:00'::timestamp as a) union (select '2001-01-01T00:00:01');
   External error: Arrow error: Invalid argument error: RowConverter column 
schema mismatch, expected Timestamp(Millisecond, None) got 
Timestamp(Nanosecond, None)
   ```
   
   ```bash
   ❯ select date_trunc('millisecond', a) from (select 
'2001-01-01T00:00:00'::timestamp as a) union (select '2001-01-01T00:00:01');
   External error: Arrow error: Invalid argument error: RowConverter column 
schema mismatch, expected Timestamp(Microsecond, None) got 
Timestamp(Nanosecond, None)
   ```
   


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

Reply via email to