formualizer_eval/
compute_prelude.rs

1//! Centralized re-exports for Arrow compute affordances used by fast paths.
2//! Pin to arrow-rs 56.x modules so call sites stay tidy.
3
4pub use arrow_cast::cast::cast_with_options;
5
6pub use arrow_select::concat::concat as concat_arrays;
7pub use arrow_select::filter::filter as filter_array;
8pub use arrow_select::zip::zip as zip_select;
9
10pub use arrow_array::ArrayRef;
11pub use arrow_schema::DataType;
12
13pub mod boolean {
14    pub use arrow::compute::kernels::boolean::{and_kleene, not, or_kleene};
15}
16
17pub mod cmp {
18    pub use arrow::compute::kernels::cmp::{eq, gt, gt_eq, lt, lt_eq, neq};
19}
20
21pub mod comparison {
22    pub use arrow::compute::kernels::comparison::{
23        like, regexp_is_match, regexp_is_match_scalar, starts_with,
24    };
25}
26
27/// Temporal casting affordance – call when a temporal kernel is required.
28pub fn cast_temporal_if_needed(arr: &ArrayRef, target: &DataType) -> ArrayRef {
29    use arrow_cast::cast::CastOptions;
30    if matches!(
31        target,
32        DataType::Date32 | DataType::Date64 | DataType::Timestamp(_, _)
33    ) {
34        cast_with_options(
35            arr,
36            target,
37            &CastOptions {
38                safe: false,
39                format_options: Default::default(),
40            },
41        )
42        .expect("temporal cast")
43    } else {
44        arr.clone()
45    }
46}