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/22 15:10:10 UTC
(arrow-rs) branch 57_maintenance updated: [57_maintenance] fix: finish methods in `PrimitiveDictionaryBuilder` discard type params (#11805)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch 57_maintenance
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/57_maintenance by this push:
new 5b3960a811 [57_maintenance] fix: finish methods in `PrimitiveDictionaryBuilder` discard type params (#11805)
5b3960a811 is described below
commit 5b3960a811da543bb74d2694d5b76f078e731843
Author: Jeffrey Vo <je...@gmail.com>
AuthorDate: Fri Oct 23 00:10:04 2026 +0900
[57_maintenance] fix: finish methods in `PrimitiveDictionaryBuilder` discard type params (#11805)
- Backport https://github.com/apache/arrow-rs/pull/11327
- For inclusion in https://github.com/apache/arrow-rs/issues/11666
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 d9544aec3b..3916b65e1a 100644
--- a/arrow-array/src/builder/primitive_dictionary_builder.rs
+++ b/arrow-array/src/builder/primitive_dictionary_builder.rs
@@ -449,7 +449,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()
@@ -481,7 +482,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()
@@ -592,15 +594,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]