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


##########
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)?;
+            Ok(dict.with_values(array_with_timezone))
         }

Review Comment:
   One edge case for converting all dictionary values before `take` is an 
unused entry that would overflow. With millisecond values `[7, i64::MAX / 1000 
+ 1]` and keys `[0, null, 0]`, the plain Parquet rows convert to `[7000, null, 
7000]` µs. I ran that through Arrow's checked conversion and `take`. Converting 
the dictionary first raises overflow on the unused entry, while gathering first 
returns those three rows. Can we gather first (or restrict conversion to 
referenced entries) and include that case alongside the non-UTC and 
referenced-overflow round trips?



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