diff --git a/vortex-array/public-api.lock b/vortex-array/public-api.lock index 11a6116e6f9..9ac5d7f13cc 100644 --- a/vortex-array/public-api.lock +++ b/vortex-array/public-api.lock @@ -222,7 +222,7 @@ pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::coerce_args(&self, pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::combine_partials(&self, partial: &mut Self::Partial, other: vortex_array::scalar::Scalar) -> vortex_error::VortexResult<()> -pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::deserialize(&self, metadata: &[u8], _session: &vortex_session::VortexSession) -> vortex_error::VortexResult +pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::deserialize(&self, _metadata: &[u8], _session: &vortex_session::VortexSession) -> vortex_error::VortexResult pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::empty_partial(&self, options: &Self::Options, input_dtype: &vortex_array::dtype::DType) -> vortex_error::VortexResult @@ -240,7 +240,7 @@ pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::reset(&self, partia pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::return_dtype(&self, _options: &Self::Options, input_dtype: &vortex_array::dtype::DType) -> core::option::Option -pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::serialize(&self, options: &Self::Options) -> vortex_error::VortexResult>> +pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::serialize(&self, _options: &Self::Options) -> vortex_error::VortexResult>> pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::to_scalar(&self, partial: &Self::Partial) -> vortex_error::VortexResult @@ -900,7 +900,7 @@ pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::coerce_args(&self, pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::combine_partials(&self, partial: &mut Self::Partial, other: vortex_array::scalar::Scalar) -> vortex_error::VortexResult<()> -pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::deserialize(&self, metadata: &[u8], _session: &vortex_session::VortexSession) -> vortex_error::VortexResult +pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::deserialize(&self, _metadata: &[u8], _session: &vortex_session::VortexSession) -> vortex_error::VortexResult pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::empty_partial(&self, options: &Self::Options, input_dtype: &vortex_array::dtype::DType) -> vortex_error::VortexResult @@ -918,7 +918,7 @@ pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::reset(&self, partia pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::return_dtype(&self, _options: &Self::Options, input_dtype: &vortex_array::dtype::DType) -> core::option::Option -pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::serialize(&self, options: &Self::Options) -> vortex_error::VortexResult>> +pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::serialize(&self, _options: &Self::Options) -> vortex_error::VortexResult>> pub fn vortex_array::aggregate_fn::fns::is_sorted::IsSorted::to_scalar(&self, partial: &Self::Partial) -> vortex_error::VortexResult diff --git a/vortex-array/src/aggregate_fn/fns/count/mod.rs b/vortex-array/src/aggregate_fn/fns/count/mod.rs index a9eb3260d75..f0617e96bfe 100644 --- a/vortex-array/src/aggregate_fn/fns/count/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/count/mod.rs @@ -31,15 +31,7 @@ impl AggregateFnVTable for Count { } fn serialize(&self, _options: &Self::Options) -> VortexResult>> { - Ok(Some(vec![])) - } - - fn deserialize( - &self, - _metadata: &[u8], - _session: &vortex_session::VortexSession, - ) -> VortexResult { - Ok(EmptyOptions) + unimplemented!("Count is not yet serializable"); } fn return_dtype(&self, _options: &Self::Options, _input_dtype: &DType) -> Option { diff --git a/vortex-array/src/aggregate_fn/fns/first/mod.rs b/vortex-array/src/aggregate_fn/fns/first/mod.rs index 8ff71191dcd..38e55607279 100644 --- a/vortex-array/src/aggregate_fn/fns/first/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/first/mod.rs @@ -44,15 +44,7 @@ impl AggregateFnVTable for First { } fn serialize(&self, _options: &Self::Options) -> VortexResult>> { - Ok(Some(vec![])) - } - - fn deserialize( - &self, - _metadata: &[u8], - _session: &vortex_session::VortexSession, - ) -> VortexResult { - Ok(EmptyOptions) + unimplemented!("First is not yet serializable"); } fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { diff --git a/vortex-array/src/aggregate_fn/fns/is_constant/mod.rs b/vortex-array/src/aggregate_fn/fns/is_constant/mod.rs index c6ae93fce5a..4df47b770de 100644 --- a/vortex-array/src/aggregate_fn/fns/is_constant/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/is_constant/mod.rs @@ -260,15 +260,7 @@ impl AggregateFnVTable for IsConstant { } fn serialize(&self, _options: &Self::Options) -> VortexResult>> { - Ok(Some(vec![])) - } - - fn deserialize( - &self, - _metadata: &[u8], - _session: &vortex_session::VortexSession, - ) -> VortexResult { - Ok(EmptyOptions) + unimplemented!("IsConstant is not yet serializable"); } fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { diff --git a/vortex-array/src/aggregate_fn/fns/is_sorted/mod.rs b/vortex-array/src/aggregate_fn/fns/is_sorted/mod.rs index 8c973b940c9..780fc492baa 100644 --- a/vortex-array/src/aggregate_fn/fns/is_sorted/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/is_sorted/mod.rs @@ -13,7 +13,6 @@ use std::fmt::Formatter; use vortex_error::VortexExpect; use vortex_error::VortexResult; -use vortex_error::vortex_bail; use self::bool::check_bool_sorted; use self::decimal::check_decimal_sorted; @@ -231,27 +230,8 @@ impl AggregateFnVTable for IsSorted { AggregateFnId::new_ref("vortex.is_sorted") } - fn serialize(&self, options: &Self::Options) -> VortexResult>> { - Ok(Some(vec![u8::from(options.strict)])) - } - - fn deserialize( - &self, - metadata: &[u8], - _session: &vortex_session::VortexSession, - ) -> VortexResult { - let &[strict_byte] = metadata else { - vortex_bail!( - "IsSorted: expected 1 byte of metadata, got {}", - metadata.len() - ); - }; - let strict = match strict_byte { - 0 => false, - 1 => true, - _ => vortex_bail!("IsSorted: expected 0 or 1 for strict, got {}", strict_byte), - }; - Ok(IsSortedOptions { strict }) + fn serialize(&self, _options: &Self::Options) -> VortexResult>> { + unimplemented!("IsSorted is not yet serializable"); } fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { diff --git a/vortex-array/src/aggregate_fn/fns/last/mod.rs b/vortex-array/src/aggregate_fn/fns/last/mod.rs index 37419dfebf9..009b487ad2d 100644 --- a/vortex-array/src/aggregate_fn/fns/last/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/last/mod.rs @@ -44,15 +44,7 @@ impl AggregateFnVTable for Last { } fn serialize(&self, _options: &Self::Options) -> VortexResult>> { - Ok(Some(vec![])) - } - - fn deserialize( - &self, - _metadata: &[u8], - _session: &vortex_session::VortexSession, - ) -> VortexResult { - Ok(EmptyOptions) + unimplemented!("Last is not yet serializable"); } fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { diff --git a/vortex-array/src/aggregate_fn/fns/min_max/mod.rs b/vortex-array/src/aggregate_fn/fns/min_max/mod.rs index ab1da46b7f3..91d178a4814 100644 --- a/vortex-array/src/aggregate_fn/fns/min_max/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/min_max/mod.rs @@ -177,15 +177,7 @@ impl AggregateFnVTable for MinMax { } fn serialize(&self, _options: &Self::Options) -> VortexResult>> { - Ok(Some(vec![])) - } - - fn deserialize( - &self, - _metadata: &[u8], - _session: &vortex_session::VortexSession, - ) -> VortexResult { - Ok(EmptyOptions) + unimplemented!("MinMax is not yet serializable"); } fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { diff --git a/vortex-array/src/aggregate_fn/fns/nan_count/mod.rs b/vortex-array/src/aggregate_fn/fns/nan_count/mod.rs index e1e3cb495c0..9a1a8e4793b 100644 --- a/vortex-array/src/aggregate_fn/fns/nan_count/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/nan_count/mod.rs @@ -85,15 +85,7 @@ impl AggregateFnVTable for NanCount { } fn serialize(&self, _options: &Self::Options) -> VortexResult>> { - Ok(Some(vec![])) - } - - fn deserialize( - &self, - _metadata: &[u8], - _session: &vortex_session::VortexSession, - ) -> VortexResult { - Ok(EmptyOptions) + unimplemented!("NanCount is not yet serializable"); } fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { diff --git a/vortex-array/src/aggregate_fn/fns/sum/mod.rs b/vortex-array/src/aggregate_fn/fns/sum/mod.rs index b4a1997fbec..4d09eac4d5b 100644 --- a/vortex-array/src/aggregate_fn/fns/sum/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/sum/mod.rs @@ -75,15 +75,7 @@ impl AggregateFnVTable for Sum { } fn serialize(&self, _options: &Self::Options) -> VortexResult>> { - Ok(Some(vec![])) - } - - fn deserialize( - &self, - _metadata: &[u8], - _session: &vortex_session::VortexSession, - ) -> VortexResult { - Ok(EmptyOptions) + unimplemented!("Sum is not yet serializable"); } fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { diff --git a/vortex-array/src/aggregate_fn/proto.rs b/vortex-array/src/aggregate_fn/proto.rs index aac2d4982d8..18231993eae 100644 --- a/vortex-array/src/aggregate_fn/proto.rs +++ b/vortex-array/src/aggregate_fn/proto.rs @@ -60,22 +60,102 @@ impl AggregateFnRef { #[cfg(test)] mod tests { use prost::Message; + use vortex_error::VortexResult; + use vortex_error::vortex_panic; use vortex_proto::expr as pb; use vortex_session::VortexSession; + use crate::ArrayRef; + use crate::Columnar; + use crate::ExecutionCtx; + use crate::aggregate_fn::AggregateFnId; use crate::aggregate_fn::AggregateFnRef; + use crate::aggregate_fn::AggregateFnVTable; use crate::aggregate_fn::AggregateFnVTableExt; use crate::aggregate_fn::EmptyOptions; - use crate::aggregate_fn::fns::sum::Sum; use crate::aggregate_fn::session::AggregateFnSession; use crate::aggregate_fn::session::AggregateFnSessionExt; + use crate::dtype::DType; + use crate::scalar::Scalar; + + /// A minimal serializable aggregate function used solely to exercise the serde round-trip. + #[derive(Clone, Debug)] + struct TestAgg; + + impl AggregateFnVTable for TestAgg { + type Options = EmptyOptions; + type Partial = (); + + fn id(&self) -> AggregateFnId { + AggregateFnId::new_ref("vortex.test.proto") + } + + fn serialize(&self, _options: &Self::Options) -> VortexResult>> { + Ok(Some(vec![])) + } + + fn deserialize( + &self, + _metadata: &[u8], + _session: &VortexSession, + ) -> VortexResult { + Ok(EmptyOptions) + } + + fn return_dtype(&self, _options: &Self::Options, input_dtype: &DType) -> Option { + Some(input_dtype.clone()) + } + + fn partial_dtype(&self, options: &Self::Options, input_dtype: &DType) -> Option { + self.return_dtype(options, input_dtype) + } + + fn empty_partial( + &self, + _options: &Self::Options, + _input_dtype: &DType, + ) -> VortexResult { + Ok(()) + } + + fn combine_partials( + &self, + _partial: &mut Self::Partial, + _other: Scalar, + ) -> VortexResult<()> { + Ok(()) + } + + fn to_scalar(&self, _partial: &Self::Partial) -> VortexResult { + vortex_panic!("TestAgg is for serde tests only"); + } + + fn reset(&self, _partial: &mut Self::Partial) {} + + fn is_saturated(&self, _partial: &Self::Partial) -> bool { + true + } + + fn accumulate( + &self, + _state: &mut Self::Partial, + _batch: &Columnar, + _ctx: &mut ExecutionCtx, + ) -> VortexResult<()> { + Ok(()) + } + + fn finalize(&self, partials: ArrayRef) -> VortexResult { + Ok(partials) + } + } #[test] fn aggregate_fn_serde() { let session = VortexSession::empty().with::(); - session.aggregate_fns().register(Sum); + session.aggregate_fns().register(TestAgg); - let agg_fn = Sum.bind(EmptyOptions); + let agg_fn = TestAgg.bind(EmptyOptions); let serialized = agg_fn.serialize_proto().unwrap(); let buf = serialized.encode_to_vec();