appletreeisyellow commented on issue #10602:
URL: https://github.com/apache/datafusion/issues/10602#issuecomment-2152717906

   > I think the returned timestamp from `date_bin` needs to be in the timezone 
that was provided as an argument (in the internal Arrow represenation)
   
   Thanks for highlighting it. Yes, this is the expected behavior. The timezone 
representation of the returned timestamp will be the same as the input 
timestamp. For example:
   
   - if the input doesn't have a timezone, then the date_bin returns timezone 
as `None`:
   ```sql
   select arrow_typeof(date_bin(interval '1 day', '2024-03-30T00:00:20Z'));
   
+---------------------------------------------------------------------------------------------------+
   | 
arrow_typeof(date_bin(IntervalMonthDayNano("18446744073709551616"),Utf8("2024-03-30T00:00:20Z")))
 |
   
+---------------------------------------------------------------------------------------------------+
   | Timestamp(Nanosecond, None)                                                
                       |
   
+---------------------------------------------------------------------------------------------------+
   
   select arrow_typeof(date_bin(interval '1 day', '2024-03-30T00:00:20'));
   
+--------------------------------------------------------------------------------------------------+
   | 
arrow_typeof(date_bin(IntervalMonthDayNano("18446744073709551616"),Utf8("2024-03-30T00:00:20")))
 |
   
+--------------------------------------------------------------------------------------------------+
   | Timestamp(Nanosecond, None)                                                
                      |
   
+--------------------------------------------------------------------------------------------------+
   
   ```
   
   - if the input has a timezone in `UTC`, then the date_bin returns timezone 
as `Some('UTC')`
   ```sql
   select arrow_typeof(date_bin(interval '1 day', '2024-03-30T00:00:20Z' AT 
TIME ZONE 'UTC'));
   
+---------------------------------------------------------------------------------------------------+
   | 
arrow_typeof(date_bin(IntervalMonthDayNano("18446744073709551616"),Utf8("2024-03-30T00:00:20Z")))
 |
   
+---------------------------------------------------------------------------------------------------+
   | Timestamp(Nanosecond, Some("UTC"))                                         
                       |
   
+---------------------------------------------------------------------------------------------------+
   ```
   
   - if the input has a timezone in `Europe/Brussels`, then the date_bin 
returns timezone as `Some('Europe/Brussels')`
   ```sql
   
   select arrow_typeof(date_bin(interval '1 day', '2024-03-30T00:00:20Z' AT 
TIME ZONE 'Europe/Brussels'));
   
+---------------------------------------------------------------------------------------------------+
   | 
arrow_typeof(date_bin(IntervalMonthDayNano("18446744073709551616"),Utf8("2024-03-30T00:00:20Z")))
 |
   
+---------------------------------------------------------------------------------------------------+
   | Timestamp(Nanosecond, Some("Europe/Brussels"))                             
                       |
   
+---------------------------------------------------------------------------------------------------+
   ```
   


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