Skip to content

Commit

Permalink
Add DecimalType support in new_null_array (#1659)
Browse files Browse the repository at this point in the history
* minor: creation of all null decimal array

* fmt
  • Loading branch information
yjshen authored May 6, 2022
1 parent 1201cb5 commit e0a527b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions arrow/src/array/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,7 @@ pub fn new_null_array(data_type: &DataType, length: usize) -> ArrayRef {
)
})
}
DataType::Decimal(_, _) => {
unimplemented!("Creating null Decimal array not yet supported")
}
DataType::Decimal(_, _) => new_null_sized_decimal(data_type, length),
}
}

Expand Down Expand Up @@ -620,6 +618,24 @@ fn new_null_sized_array<T: ArrowPrimitiveType>(
})
}

#[inline]
fn new_null_sized_decimal(data_type: &DataType, length: usize) -> ArrayRef {
make_array(unsafe {
ArrayData::new_unchecked(
data_type.clone(),
length,
Some(length),
Some(MutableBuffer::new_null(length).into()),
0,
vec![Buffer::from(vec![
0u8;
length * std::mem::size_of::<i128>()
])],
vec![],
)
})
}

/// Creates a new array from two FFI pointers. Used to import arrays from the C Data Interface
/// # Safety
/// Assumes that these pointers represent valid C Data Interfaces, both in memory
Expand Down

0 comments on commit e0a527b

Please sign in to comment.