mod aggregates;
mod compute;
mod decimal;
mod decimal_aggregates;
mod decimal_cast;
mod decimal_compare;
mod decimal_fallback;
mod decimal_stored;
mod encoding;
mod numeric;
mod serde;
use std::sync::LazyLock;
use vortex_buffer::buffer;
use vortex_error::VortexExpect;
use vortex_error::VortexResult;
use vortex_session::VortexSession;
use crate::ArrayRef;
use crate::Canonical;
use crate::ExecutionCtx;
use crate::IntoArray;
use crate::arrays::PrimitiveArray;
use crate::arrays::Widen;
use crate::arrays::WidenArray;
use crate::arrays::widen::WidenArraySlotsExt;
use crate::assert_arrays_eq;
use crate::builtins::ArrayBuiltins;
use crate::dtype::DType;
use crate::dtype::PType;
use crate::scalar_fn::fns::operators::Operator;
use crate::validity::Validity;
static SESSION: LazyLock<VortexSession> = LazyLock::new(VortexSession::empty);
fn widen(values: impl IntoArray, logical: PType) -> WidenArray {
let values = values.into_array();
let dtype = DType::Primitive(logical, values.dtype().nullability());
WidenArray::try_new(values, dtype).vortex_expect("fixture values are narrower integers")
}
fn stored_ptype(array: &ArrayRef) -> PType {
match array.as_opt::<Widen>() {
Some(widen) => widen.values().dtype().as_ptype(),
None => array.dtype().as_ptype(),
}
}
fn canonical(array: &ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult<ArrayRef> {
Ok(array.clone().execute::<Canonical>(ctx)?.into_array())
}
#[track_caller]
fn assert_compare_matches_canonical(
lhs: &ArrayRef,
rhs: &ArrayRef,
operator: Operator,
ctx: &mut ExecutionCtx,
) -> VortexResult<()> {
let canonical_lhs = canonical(lhs, ctx)?;
let canonical_rhs = canonical(rhs, ctx)?;
let expected = canonical_lhs.binary(canonical_rhs.clone(), operator)?;
assert_arrays_eq!(lhs.binary(rhs.clone(), operator)?, expected, ctx);
let expected = canonical_rhs.binary(canonical_lhs, operator)?;
assert_arrays_eq!(rhs.binary(lhs.clone(), operator)?, expected, ctx);
Ok(())
}
fn signed() -> WidenArray {
let values = [Some(i8::MIN), Some(-1), Some(0), Some(1), Some(i8::MAX)];
widen(PrimitiveArray::from_option_iter(values), PType::I64)
}
fn unsigned() -> WidenArray {
let values = [Some(0u16), Some(1), Some(255), Some(256), Some(u16::MAX)];
widen(PrimitiveArray::from_option_iter(values), PType::U32)
}
fn non_nullable() -> WidenArray {
widen(buffer![i16::MIN, -1, 0, 1, i16::MAX], PType::I32)
}
fn partially_valid() -> WidenArray {
let values = [Some(-300i16), None, Some(0), None, Some(300)];
widen(PrimitiveArray::from_option_iter(values), PType::I64)
}
fn all_invalid() -> WidenArray {
let values = PrimitiveArray::new(buffer![i8::MIN, 0, i8::MAX], Validity::AllInvalid);
widen(values, PType::I64)
}
fn one_row() -> WidenArray {
widen(buffer![u32::MAX], PType::U64)
}