Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DictionaryArray in temporal kernels #2623

Merged
merged 7 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions arrow/src/array/array_primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl<'a, T: ArrowPrimitiveType> ArrayAccessor for &'a PrimitiveArray<T> {
}
}

fn as_datetime<T: ArrowPrimitiveType>(v: i64) -> Option<NaiveDateTime> {
pub(crate) fn as_datetime<T: ArrowPrimitiveType>(v: i64) -> Option<NaiveDateTime> {
match T::DATA_TYPE {
DataType::Date32 => Some(temporal_conversions::date32_to_datetime(v as i32)),
DataType::Date64 => Some(temporal_conversions::date64_to_datetime(v)),
Expand All @@ -233,7 +233,7 @@ fn as_date<T: ArrowPrimitiveType>(v: i64) -> Option<NaiveDate> {
as_datetime::<T>(v).map(|datetime| datetime.date())
}

fn as_time<T: ArrowPrimitiveType>(v: i64) -> Option<NaiveTime> {
pub(crate) fn as_time<T: ArrowPrimitiveType>(v: i64) -> Option<NaiveTime> {
match T::DATA_TYPE {
DataType::Time32(unit) => {
// safe to immediately cast to u32 as `self.value(i)` is positive i32
Expand Down Expand Up @@ -1123,13 +1123,13 @@ mod tests {
use crate::compute::hour;
let a: TimestampMicrosecondArray = vec![37800000000, 86339000000].into();

let b = hour(&a).unwrap();
let b = hour::<TimestampMicrosecondType, _>(&a).unwrap();
assert_eq!(10, b.value(0));
assert_eq!(23, b.value(1));

let a = a.with_timezone(String::from("America/Los_Angeles"));

let b = hour(&a).unwrap();
let b = hour::<TimestampMicrosecondType, _>(&a).unwrap();
assert_eq!(2, b.value(0));
assert_eq!(15, b.value(1));
}
Expand Down
2 changes: 2 additions & 0 deletions arrow/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ pub use self::array::make_array;
pub use self::array::new_empty_array;
pub use self::array::new_null_array;

pub(crate) use self::array_primitive::{as_datetime, as_time};

///
/// # Example: Using `collect`
/// ```
Expand Down