sunchao commented on code in PR #7781:
URL: https://github.com/apache/datafusion-comet/pull/7781#discussion_r4735274158


##########
native/spark-expr/src/utils.rs:
##########
@@ -152,12 +116,10 @@ pub fn array_with_timezone(
         DataType::Dictionary(_, value_type)
             if matches!(value_type.as_ref(), &DataType::Timestamp(_, _)) =>
         {
-            let dict = as_dictionary_array::<Int32Type>(&array);
-            let array = 
as_primitive_array::<TimestampMicrosecondType>(dict.values());
+            let dict = array.as_any_dictionary();
             let array_with_timezone =
-                array_with_timezone(Arc::new(array.clone()) as ArrayRef, 
timezone, to_type)?;
-            let dict = dict.with_values(array_with_timezone);
-            Ok(Arc::new(dict))
+                array_with_timezone(Arc::clone(dict.values()), timezone, 
to_type)?;

Review Comment:
   Could we route top-level timestamp dictionaries through 
`CometCastColumnExpr`, decode the referenced rows, and apply the same Parquet 
conversion as for plain timestamps? The scalar `Cast` path here applies the 
session timezone and bypasses Parquet’s checked millis-to-micros conversion. I 
reproduced both differences with `scan_parquet` in legacy mode, session zone 
`America/Los_Angeles`, and no filters.
   
   | NTZ input in ms | Requested type | Plain column | Dictionary column |
   |---|---|---|---|
   | `7` | `Timestamp(us, UTC)` | `7,000 µs` | `28,800,007,000 µs` |
   | `i64::MAX / 1000 + 1` | `Timestamp(us, None)` | `long overflow` | `NULL` |
   
   Please add both round trips. Keeping the fix in schema adaptation would also 
preserve [SQL cast vs. Parquet scan 
semantics](https://github.com/apache/datafusion-comet/blob/98728a63e115622067d8f2731e6e579fbf653277/docs/source/contributor-guide/timezones.md#scans).



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