-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Derive ScalarUDFImpl
equality, hash from Eq
, Hash
traits
#17164
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
Conversation
6037ccb
to
bff9ef1
Compare
Follows similar change for `WindowUDFImpl` and `AggregateUDFImpl`, i.e. the 8494a39 and b8bf7c5 commits. Previously, the `ScalarUDFImpl` trait contained `equals` and `hash_value` methods with contracts following the `Eq` and `Hash` traits. However, the existence of default implementations of these methods made it error-prone, with many functions (scalar, aggregate, window) missing to customize the equals even though they ought to. There is no fix to this that's not an API breaking change, so a breaking change is warranted. Removing the default implementations would be enough of a solution, but at the cost of a lot of boilerplate needed in implementations. Instead, this removes the methods from the trait, and reuses `DynEq`, `DynHash` traits used previously only for physical expressions. This allows for functions to provide their implementations using no more than `#[derive(PartialEq, Eq, Hash)]` in a typical case.
bff9ef1
to
e7a9934
Compare
|
||
- search for `\#\[derive\(Debug\)\](\n *(pub )?struct \w+ \{\n *signature\: Signature\,\n *\})`, | ||
- replace with `#[derive(Debug, PartialEq, Eq, Hash)]$1`, | ||
- review all the changes and make sure only function structs were changed. |
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.
Here is the only non-mechanical change in this PR.
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.
for reference, due to how DF functions are written, i used a different regex
\#\[derive\(Debug\)\](\n *(pub(\((super|crate)\))? )?struct \w+ \{\n( *name: String,\n)? *signature\: Signature\,\n( *aliases: Vec<String>,\n)? *\})
- still not perfect, eg some functions derive Clone (just because they can) and the pattern doesn't cater for this
- it's unlikely that downstream projects have fields such as
name
andaliases
in their functions, so I didn't cater for these in the upgrade guide.
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.
loogs good to me -- thanks @findepi and @timsaucer
Follows similar change for
WindowUDFImpl
andAggregateUDFImpl
, i.e.the 8494a39 and b8bf7c5 commits.
Previously, the
ScalarUDFImpl
trait containedequals
andhash_value
methods with contracts following theEq
andHash
traits. However, the existence of default implementations of these
methods made it error-prone, with many functions (scalar, aggregate,
window) missing to customize the equals even though they ought to.
There is no fix to this that's not an API breaking change, so a breaking
change is warranted.
Removing the default implementations would be enough of a solution, but
at the cost of a lot of boilerplate needed in implementations.
Instead, this removes the methods from the trait, and reuses
DynEq
,DynHash
traits used previously only for physical expressions. Thisallows for functions to provide their implementations using no more than
#[derive(PartialEq, Eq, Hash)]
in a typical case.WindowUDFImpl
equality, hash fromEq
,Hash
traits #17081AggregateUDFImpl
equality, hash fromEq
,Hash
traits #17130ScalarUDFImpl
) #16868ScalarUDFImpl::{equals,hash_value}
withUdfHash
,UdfEq
traits #16871