-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix hash/equality issues for ScalarFunctionExpr #17078
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
Fix hash/equality issues for ScalarFunctionExpr #17078
Conversation
The equality implementation for ScalarFunctionExpr could incorrectly return true when one compared object has more config options. This is because the `iterator.zip(other)` terminates whenever one of the zipped iterators terminates.
The `ScalarFunctionExpr` equality compares config options ignoring the order, and so hash should ignore order too.
Use standard pattern for implementing `DynEq` and `DynHash` -- they should be derived from `Eq` and `Hash` implementations.
alamb
left a comment
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.
Thank you @findepi
comphead
left a comment
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 just to refresh my memory https://doc.rust-lang.org/std/cmp/trait.Eq.html so
a == b will effectively call PartialEq and we dont need separate impl for Eq?
yes
|
* Fix equality impl for ScalarFunctionExpr The equality implementation for ScalarFunctionExpr could incorrectly return true when one compared object has more config options. This is because the `iterator.zip(other)` terminates whenever one of the zipped iterators terminates. * Fix hash/equality inconsistency for ScalarFunctionExpr The `ScalarFunctionExpr` equality compares config options ignoring the order, and so hash should ignore order too. * Derive dyn eq,hash for ScalarFunctionExpr from plain eq, hash Use standard pattern for implementing `DynEq` and `DynHash` -- they should be derived from `Eq` and `Hash` implementations. * Fix doc example for implementing PhysicalExpr * Short-circuit expensive operations in eq impl for ScalarFunctionExpr
DynEqimplementation forScalarFunctionExpr; it could returntruefor non equal valuesDynHashimplementation forScalarFunctionExprto be consistent with equals