frisbeeman commented on code in PR #1968:
URL: https://github.com/apache/iceberg-rust/pull/1968#discussion_r2651025745


##########
crates/integrations/datafusion/src/physical_plan/expr_to_predicate.rs:
##########
@@ -214,6 +217,26 @@ fn scalar_value_to_datum(value: &ScalarValue) -> 
Option<Datum> {
         ScalarValue::LargeUtf8(Some(v)) => Some(Datum::string(v.clone())),
         ScalarValue::Date32(Some(v)) => Some(Datum::date(*v)),
         ScalarValue::Date64(Some(v)) => Some(Datum::date((*v / MILLIS_PER_DAY) 
as i32)),
+        ScalarValue::TimestampSecond(Some(v), Some(tz)) if 
tz.as_ref().eq(UTC_TIME_ZONE) => {
+            Some(Datum::timestamptz_micros(*v * MICROS_PER_SEC))
+        }
+        ScalarValue::TimestampSecond(Some(v), None) => {
+            Some(Datum::timestamp_micros(*v * MICROS_PER_SEC))
+        }
+        ScalarValue::TimestampMillisecond(Some(v), Some(tz)) if 
tz.as_ref().eq(UTC_TIME_ZONE) => {
+            Some(Datum::timestamptz_micros(*v * MICROS_PER_MILLIS))
+        }
+        ScalarValue::TimestampMillisecond(Some(v), None) => {
+            Some(Datum::timestamp_micros(*v * MICROS_PER_MILLIS))
+        }
+        ScalarValue::TimestampMicrosecond(Some(v), Some(tz)) if 
tz.as_ref().eq(UTC_TIME_ZONE) => {
+            Some(Datum::timestamptz_micros(*v))
+        }
+        ScalarValue::TimestampMicrosecond(Some(v), None) => 
Some(Datum::timestamp_micros(*v)),
+        ScalarValue::TimestampNanosecond(Some(v), Some(tz)) if 
tz.as_ref().eq(UTC_TIME_ZONE) => {
+            Some(Datum::timestamptz_nanos(*v))
+        }
+        ScalarValue::TimestampNanosecond(Some(v), None) => 
Some(Datum::timestamp_nanos(*v)),

Review Comment:
   Based on our discussion I fix my code. From my wrong POV `v` wasn't UTC. But 
if we check datafusion code, for example 
https://github.com/apache/datafusion/blob/83ed19235b700a2bd41283301cfd344cb5b565bc/datafusion/sql/src/unparser/expr.rs#L3265-L3270
   it already contains adjusted UTC value.
   ```rust
   (
       Arc::clone(&default_dialect),
       ScalarValue::TimestampMillisecond(
           Some(1757934000123),
           Some("+01:00".into()),
       ),
       "CAST('2025-09-15 12:00:00.123 +01:00' AS TIMESTAMP)",
   ),
   ```
   
   Code can be simplified.



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