jhorstmann commented on code in PR #6383:
URL: https://github.com/apache/arrow-rs/pull/6383#discussion_r1758773588


##########
arrow-cast/src/cast/dictionary.rs:
##########
@@ -203,10 +203,36 @@ pub(crate) fn cast_to_dictionary<K: 
ArrowDictionaryKeyType>(
         UInt32 => pack_numeric_to_dictionary::<K, UInt32Type>(array, 
dict_value_type, cast_options),
         UInt64 => pack_numeric_to_dictionary::<K, UInt64Type>(array, 
dict_value_type, cast_options),
         Decimal128(_, _) => {
-            pack_numeric_to_dictionary::<K, Decimal128Type>(array, 
dict_value_type, cast_options)
+            // pack_numeric_to_dictionary loses the precision and scale so we 
have to perform a
+            // second cast
+            let decimal_dict_max_precision_scale = 
pack_numeric_to_dictionary::<K, Decimal128Type>(

Review Comment:
   The `PrimitiveDictionaryBuilder` used during casting seems to already loose 
the custom precision and scale. Its `new` or `with_capacity` methods use the 
default data type of the generic `ArrowPrimitiveType`. Maybe adding a 
`with_capacity_and_data_type` method that calls `values_builder.with_data_type` 
could be a more general fix.
   
   
https://github.com/apache/arrow-rs/blob/53.0.0/arrow-array/src/builder/primitive_builder.rs#L152
   
https://github.com/apache/arrow-rs/blob/53.0.0/arrow-cast/src/cast/dictionary.rs#L299



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