From d07a7e1e02f4773777f5e066433492f30e0ec3ff Mon Sep 17 00:00:00 2001 From: Josh Pschorr Date: Thu, 5 Dec 2024 14:19:44 -0800 Subject: [PATCH] Make `bind` consuming (#524) --- partiql-eval/src/eval/expr/coll.rs | 4 ++-- partiql-eval/src/eval/expr/datetime.rs | 2 +- partiql-eval/src/eval/expr/functions.rs | 4 ++-- partiql-eval/src/eval/expr/mod.rs | 2 +- partiql-eval/src/eval/expr/operators.rs | 14 +++++++------- partiql-eval/src/eval/expr/path.rs | 2 +- partiql-eval/src/eval/expr/pattern_match.rs | 4 ++-- partiql-eval/src/eval/expr/strings.rs | 10 +++++----- partiql-eval/src/plan.rs | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/partiql-eval/src/eval/expr/coll.rs b/partiql-eval/src/eval/expr/coll.rs index 5991f670..9c2733e4 100644 --- a/partiql-eval/src/eval/expr/coll.rs +++ b/partiql-eval/src/eval/expr/coll.rs @@ -36,7 +36,7 @@ pub(crate) enum EvalCollFn { impl BindEvalExpr for EvalCollFn { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { fn create( @@ -70,7 +70,7 @@ impl BindEvalExpr for EvalCollFn { PartiqlShapeBuilder::init_or_get().new_static(Static::Bag(BagType::new_any())), ])]; - match *self { + match self { EvalCollFn::Count(setq) => { create::<{ STRICT }, _>(any_elems, args, move |it| it.coll_count(setq)) } diff --git a/partiql-eval/src/eval/expr/datetime.rs b/partiql-eval/src/eval/expr/datetime.rs index c90dd459..0ce768f9 100644 --- a/partiql-eval/src/eval/expr/datetime.rs +++ b/partiql-eval/src/eval/expr/datetime.rs @@ -32,7 +32,7 @@ pub(crate) enum EvalExtractFn { impl BindEvalExpr for EvalExtractFn { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { #[inline] diff --git a/partiql-eval/src/eval/expr/functions.rs b/partiql-eval/src/eval/expr/functions.rs index 485ddac0..9106cbd8 100644 --- a/partiql-eval/src/eval/expr/functions.rs +++ b/partiql-eval/src/eval/expr/functions.rs @@ -18,10 +18,10 @@ use std::ops::ControlFlow; impl BindEvalExpr for ScalarFnCallSpec { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { - let plan = self.output.clone(); + let plan = self.output; Ok(Box::new(EvalExprFnScalar::<{ STRICT }> { plan, args })) } } diff --git a/partiql-eval/src/eval/expr/mod.rs b/partiql-eval/src/eval/expr/mod.rs index 4f19c0bf..449c9290 100644 --- a/partiql-eval/src/eval/expr/mod.rs +++ b/partiql-eval/src/eval/expr/mod.rs @@ -60,7 +60,7 @@ pub enum BindError { /// A trait for binding an expression to its arguments into an `EvalExpr` pub trait BindEvalExpr: Debug { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError>; } diff --git a/partiql-eval/src/eval/expr/operators.rs b/partiql-eval/src/eval/expr/operators.rs index 6cecac0a..17e65215 100644 --- a/partiql-eval/src/eval/expr/operators.rs +++ b/partiql-eval/src/eval/expr/operators.rs @@ -35,7 +35,7 @@ impl Debug for EvalLitExpr { impl BindEvalExpr for EvalLitExpr { fn bind( - &self, + self, _args: Vec>, ) -> Result, BindError> { Ok(Box::new(self.clone())) @@ -77,7 +77,7 @@ pub(crate) enum EvalOpUnary { impl BindEvalExpr for EvalOpUnary { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { let any_num = PartiqlShapeBuilder::init_or_get().any_of(type_numeric!()); @@ -177,7 +177,7 @@ impl ArgChecker impl BindEvalExpr for EvalOpBinary { #[inline] fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { type AndCheck = BoolShortCircuitArgChecker>; @@ -345,7 +345,7 @@ pub(crate) struct EvalBetweenExpr {} impl BindEvalExpr for EvalBetweenExpr { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { let types = [type_dynamic!(), type_dynamic!(), type_dynamic!()]; @@ -363,7 +363,7 @@ pub(crate) struct EvalFnExists {} impl BindEvalExpr for EvalFnExists { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { UnaryValueExpr::create_with_any::<{ STRICT }, _>(args, |v| { @@ -383,7 +383,7 @@ pub(crate) struct EvalFnAbs {} impl BindEvalExpr for EvalFnAbs { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { let nums = PartiqlShapeBuilder::init_or_get().any_of(type_numeric!()); @@ -404,7 +404,7 @@ pub(crate) struct EvalFnCardinality {} impl BindEvalExpr for EvalFnCardinality { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { let shape_builder = PartiqlShapeBuilder::init_or_get(); diff --git a/partiql-eval/src/eval/expr/path.rs b/partiql-eval/src/eval/expr/path.rs index cbfdc247..fb3e8f5a 100644 --- a/partiql-eval/src/eval/expr/path.rs +++ b/partiql-eval/src/eval/expr/path.rs @@ -178,7 +178,7 @@ pub(crate) enum EvalVarRef { impl BindEvalExpr for EvalVarRef { fn bind( - &self, + self, _: Vec>, ) -> Result, BindError> { Ok(match self { diff --git a/partiql-eval/src/eval/expr/pattern_match.rs b/partiql-eval/src/eval/expr/pattern_match.rs index a6004e5b..e1b71292 100644 --- a/partiql-eval/src/eval/expr/pattern_match.rs +++ b/partiql-eval/src/eval/expr/pattern_match.rs @@ -43,7 +43,7 @@ impl EvalLikeMatch { impl BindEvalExpr for EvalLikeMatch { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { let pattern = self.pattern.clone(); @@ -63,7 +63,7 @@ pub(crate) struct EvalLikeNonStringNonLiteralMatch {} impl BindEvalExpr for EvalLikeNonStringNonLiteralMatch { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { let types = [type_string!(), type_string!(), type_string!()]; diff --git a/partiql-eval/src/eval/expr/strings.rs b/partiql-eval/src/eval/expr/strings.rs index d5b2ff9e..879cec38 100644 --- a/partiql-eval/src/eval/expr/strings.rs +++ b/partiql-eval/src/eval/expr/strings.rs @@ -28,7 +28,7 @@ pub(crate) enum EvalStringFn { impl BindEvalExpr for EvalStringFn { #[inline] fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { #[inline] @@ -69,7 +69,7 @@ pub(crate) enum EvalTrimFn { impl BindEvalExpr for EvalTrimFn { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { let create = |f: for<'a> fn(&'a str, &'a str) -> &'a str| { @@ -107,7 +107,7 @@ pub(crate) struct EvalFnPosition {} impl BindEvalExpr for EvalFnPosition { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { BinaryValueExpr::create_typed::( @@ -129,7 +129,7 @@ pub(crate) struct EvalFnSubstring {} impl BindEvalExpr for EvalFnSubstring { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { match args.len() { @@ -179,7 +179,7 @@ pub(crate) struct EvalFnOverlay {} impl BindEvalExpr for EvalFnOverlay { fn bind( - &self, + self, args: Vec>, ) -> Result, BindError> { fn overlay(value: &str, replacement: &str, offset: i64, length: usize) -> Value { diff --git a/partiql-eval/src/plan.rs b/partiql-eval/src/plan.rs index f269fe34..2e426e33 100644 --- a/partiql-eval/src/plan.rs +++ b/partiql-eval/src/plan.rs @@ -755,7 +755,7 @@ impl<'c> EvaluatorPlanner<'c> { Ok(Box::new(ErrorNode::new()) as Box) } - Some(overload) => overload.bind::<{ STRICT }>(args), + Some(overload) => overload.clone().bind::<{ STRICT }>(args), } } FunctionEntryFunction::Aggregate() => {