sdf-jkl commented on issue #9337:
URL: https://github.com/apache/arrow-rs/issues/9337#issuecomment-3842152008

   @alamb @codephage2020 
   
   The current `make_value` API takes a `NaiveDateTime` and returns the `UTC` 
timestamp value in its `TimeUnit`.
   ```rust
   impl ArrowTimestampType for TimestampMicrosecondType {
       const UNIT: TimeUnit = TimeUnit::Microsecond;
   
       fn make_value(naive: NaiveDateTime) -> Option<i64> {
           let utc = naive.and_utc();
           let micros = utc.timestamp().checked_mul(1_000_000)?;
           micros.checked_add(utc.timestamp_subsec_micros() as i64)
       }
   }
   ```
   In `date_to_scalar` case, we have a `NaiveDate` and want to convert to 
scalar.
   
   I wonder if we should change the scope of the new API to something like 
`with_timezone/to_timezone` where `with_timezone(naive: NaiveDateTime, tz: 
Option<Tz>) -> Option<i64>`.
   
    It would keep the same logic as `make_value` but also check if `tz` is 
`Some()` and use it instead of `UTC`. If `None`, fallback to `UTC`.
   Would help reduce the code here:
   
https://github.com/apache/datafusion/pull/19733/changes#diff-6e1c7798dffd9a3d0f1b7a22bc2910330ed9681cba8e879677e24a66e7b26042R329-R346


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