-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Derive UDF equality from PartialEq, Hash #16842
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
base: main
Are you sure you want to change the base?
Derive UDF equality from PartialEq, Hash #16842
Conversation
e6bf41d
to
234c978
Compare
This is POC only for now. Note the PR goals:
|
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.
😍
@@ -1260,6 +1260,24 @@ pub fn collect_subquery_cols( | |||
}) | |||
} | |||
|
|||
#[macro_export] | |||
macro_rules! udf_equals_hash { |
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.
Is this macro needed if we proceed with the proposal in #16677 (comment) ?
It seems like that proposal is pretty awesome -- is it possible to do incrementally, or does it require one massive 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.
Is this macro needed if we proceed with the proposal in #16677 (comment) ?
No
But it's a good transition step.
It allows us to introduce PartialEq, Hash implementations for functions where PartialEq, Hash may not be trivial (Hashmap
, Arc<Fn>
).
On the usage side, the temporary udf_equals_hash!(...)
line is low cost for that and easy to remove in the second step.
It seems like that proposal is pretty awesome -- is it possible to do incrementally, or does it require one massive PR ?
The change proposed in this PR -- delegation to PartialEq, Hash with udf_equals_hash
macro -- can be incremental.
The change proposed in #16677 (comment) is not incremental.
Reduce boilerplate in cases where implementation of `{ScalarUDFImpl,AggregateUDFImpl,WindowUDFImpl}::{equals,hash_code}` can be derived using standard `PartialEq` and `Hash` traits. This is code complexity reduction. While valuable on its own, this also prepares for more automatic derivation of UDF equals/hash and/or removal of default implementations (which currently are error-prone).
234c978
to
493ac60
Compare
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.
Thanks @findepi -- this is a nice improvement I think
Reduce boilerplate in cases where implementation of
{ScalarUDFImpl,AggregateUDFImpl,WindowUDFImpl}::{equals,hash_value}
can be derived using standardPartialEq
andHash
traits.This is code complexity reduction. Follows #16781
While valuable on its own, this also prepares for more automatic derivation of UDF equals/hash and/or removal of default implementations (which currently are error-prone) -- #16677
ScalarUDFImpl
) equality from PartialEq, Hash #16865