You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2026/10/21 13:09:50 UTC
(arrow-rs) branch 58_maintenance updated: [58_maintenance] fix: finish methods in `PrimitiveDictionaryBuilder` discard type params (#11705)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch 58_maintenance
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/58_maintenance by this push:
new 93e7672af5 [58_maintenance] fix: finish methods in `PrimitiveDictionaryBuilder` discard type params (#11705)
93e7672af5 is described below
commit 93e7672af574d00659057809900e398513843b29
Author: Jeffrey Vo <je...@gmail.com>
AuthorDate: Wed Oct 21 22:09:44 2026 +0900
[58_maintenance] fix: finish methods in `PrimitiveDictionaryBuilder` discard type params (#11705)
- Backport https://github.com/apache/arrow-rs/pull/11327
- For inclusion in https://github.com/apache/arrow-rs/issues/11665
Cherry-pick of
https://github.com/apache/arrow-rs/commit/3a355988921a28b90855ea8a866223baf3f0e5e1
Co-authored-by: Neil Conway <ne...@gmail.com>
---
.../src/builder/primitive_dictionary_builder.rs | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/arrow-array/src/builder/primitive_dictionary_builder.rs b/arrow-array/src/builder/primitive_dictionary_builder.rs
index 4f21871974..48b097e260 100644
--- a/arrow-array/src/builder/primitive_dictionary_builder.rs
+++ b/arrow-array/src/builder/primitive_dictionary_builder.rs
@@ -453,7 +453,8 @@ where
let values = self.values_builder.finish_cloned();
let keys = self.keys_builder.finish_cloned();
- let data_type = DataType::Dictionary(Box::new(K::DATA_TYPE), Box::new(V::DATA_TYPE));
+ let data_type =
+ DataType::Dictionary(Box::new(K::DATA_TYPE), Box::new(values.data_type().clone()));
let builder = keys
.into_data()
@@ -485,7 +486,8 @@ where
let values = self.values_builder.finish_cloned();
let keys = self.keys_builder.finish();
- let data_type = DataType::Dictionary(Box::new(K::DATA_TYPE), Box::new(V::DATA_TYPE));
+ let data_type =
+ DataType::Dictionary(Box::new(K::DATA_TYPE), Box::new(values.data_type().clone()));
let builder = keys
.into_data()
@@ -596,15 +598,16 @@ mod tests {
keys_builder,
values_builder,
);
+ let expected = DataType::Dictionary(
+ Box::new(DataType::Int32),
+ Box::new(DataType::Decimal128(1, 2)),
+ );
+ assert_eq!(builder.finish_cloned().data_type(), &expected);
+ assert_eq!(builder.finish_preserve_values().data_type(), &expected);
+
let dict_array = builder.finish();
assert_eq!(dict_array.value_type(), DataType::Decimal128(1, 2));
- assert_eq!(
- dict_array.data_type(),
- &DataType::Dictionary(
- Box::new(DataType::Int32),
- Box::new(DataType::Decimal128(1, 2)),
- )
- );
+ assert_eq!(dict_array.data_type(), &expected);
}
#[test]