-
Notifications
You must be signed in to change notification settings - Fork 130
Scalar functions #5561
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
Scalar functions #5561
Conversation
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
CodSpeed Performance ReportMerging #5561 will degrade performances by 10.34%Comparing Summary
Benchmarks breakdown
Footnotes
|
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
| pub fn arity(&self) -> Arity { | ||
| self.vtable.as_dyn().arity(self.options) | ||
| } | ||
|
|
||
| pub fn identity_element(&self) -> Option<Scalar> { | ||
| self.vtable.as_dyn().identity_element(self.options) | ||
| } | ||
|
|
||
| pub fn absorbing_element(&self) -> Option<Scalar> { | ||
| self.vtable.as_dyn().absorbing_element(self.options) | ||
| } | ||
|
|
||
| pub fn is_commutative(&self) -> bool { | ||
| self.vtable.as_dyn().is_commutative(self.options) | ||
| } | ||
|
|
||
| pub fn is_idempotent(&self) -> bool { | ||
| self.vtable.as_dyn().is_idempotent(self.options) | ||
| } | ||
|
|
||
| pub fn is_involution(&self) -> bool { | ||
| self.vtable.as_dyn().is_involution(self.options) | ||
| } | ||
|
|
||
| pub fn monotonicity(&self, arg_idx: usize) -> Monotonicity { | ||
| self.vtable.as_dyn().monotonicity(self.options, arg_idx) | ||
| } | ||
|
|
||
| pub fn null_handling(&self) -> NullHandling { | ||
| self.vtable.as_dyn().null_handling(self.options) | ||
| } | ||
|
|
||
| pub fn arg_name(&self, arg_idx: usize) -> Option<String> { | ||
| self.vtable.as_dyn().arg_name(self.options, arg_idx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need all of these can we add them once we need them?
| /// NULL in any argument produces NULL output. | ||
| /// | ||
| /// This is standard SQL behavior for most scalar functions. | ||
| /// Enables simplification when any argument is known to be NULL. | ||
| Propagate, | ||
|
|
||
| /// NULL is short-circuited when paired with the absorbing element. | ||
| /// | ||
| /// This is a special case where the absorbing element "wins" over NULL. | ||
| /// | ||
| /// # Examples | ||
| /// - `AND_KLEENE(false, NULL)` → `false` (false absorbs NULL) | ||
| /// - `OR_KLEENE(true, NULL)` → `true` (true absorbs NULL) | ||
| AbsorbsNull, | ||
|
|
||
| /// The function has special NULL semantics that don't follow | ||
| /// simple propagation rules. | ||
| /// | ||
| /// This prevents any simplifications based on NULL arguments. | ||
| /// | ||
| /// # Examples | ||
| /// - `IS NULL`, `IS NOT NULL`: NULL → true/false | ||
| /// - `COALESCE`: returns first non-NULL argument | ||
| /// - `NULLIF`: conditionally produces NULL | ||
| #[default] | ||
| Custom, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AND_KLEENE might absorb and might not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It absorbs null when paired with the absorbing element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add this in a different PR if we want this
|
Can we remove stuff from the PR that is not required to impl ScalarFunc |
| NullHandling::AbsorbsNull | NullHandling::Custom => { | ||
| // We cannot guarantee that the array is all valid without evaluating the function | ||
| false | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is approximate which I am not sure was the original behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, but its only used for approximate short-circuits and we have to move the Array trait towards this definition anyway since we want to defer compute.
| /// - `COALESCE`: returns first non-NULL argument | ||
| /// - `NULLIF`: conditionally produces NULL | ||
| #[default] | ||
| Custom, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we call this unknown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I prefer custom? It's not that it's unknown. It just isn't describable in a useful way
vortex-array/src/functions/vtable.rs
Outdated
| /// for better common subexpression elimination and pattern matching. | ||
| /// | ||
| /// # Examples | ||
| /// - Commutative: `+`, `*`, `AND`, `OR`, `=`, `!=`, `MIN`, `MAX` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely a typed property?
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
Introduces the traits required to define abstract scalar functions and wrap them up as either expressions or arrays.
This is one of the types of functions that we will split the generic ComputeFn trait into and allows us to lazily defer scalar compute in the array tree.
We don't add them in this PR, but there may be some properties that are useful for ScalarFns in some form: