alamb commented on code in PR #9305:
URL: https://github.com/apache/arrow-rs/pull/9305#discussion_r2746497121
##########
arrow-array/src/builder/primitive_builder.rs:
##########
@@ -100,7 +99,8 @@ pub type Decimal256Builder =
PrimitiveBuilder<Decimal256Type>;
pub struct PrimitiveBuilder<T: ArrowPrimitiveType> {
values_builder: Vec<T::Native>,
null_buffer_builder: NullBufferBuilder,
- data_type: DataType,
+ /// Optional data type override (e.g. to add timezone or precision/scale)
Review Comment:
This time I tried switching to use Option<DataType> so we only pay the extra
type check when there is actually a datatype override
##########
arrow-array/src/builder/primitive_builder.rs:
##########
@@ -183,15 +183,14 @@ impl<T: ArrowPrimitiveType> PrimitiveBuilder<T> {
///
/// # Panics
///
- /// This method panics if `data_type` is not
[PrimitiveArray::is_compatible]
+ /// This method will not panic, but [`Self::build`], [`Self::finish`] will
panics if `data_type` is
+ /// not [PrimitiveArray::is_compatible] with the builder's primitive type
+ /// `T`.
pub fn with_data_type(self, data_type: DataType) -> Self {
- assert!(
Review Comment:
this assert is done as part of the PrimitiveArray::with_type later on
I also updated the tests to show that
--
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]