-
Notifications
You must be signed in to change notification settings - Fork 1.8k
chore: utilize trait upcasting for AsyncScalarUDF PartialEq & Hash #17872
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
datafusion/expr/src/async_udf.rs
Outdated
| // Inner is distinct arc -> still equal | ||
| let a = AsyncScalarUDF::new(Arc::new(TestAsyncUDFImpl1 { a: 1 })); | ||
| let b = AsyncScalarUDF::new(Arc::new(TestAsyncUDFImpl1 { a: 1 })); | ||
| assert_eq!(a, b); | ||
| let mut set = HashSet::new(); | ||
| set.insert(a); | ||
| assert!(set.contains(&b)); |
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 test would have failed before; it succeeding is new behaviour introduced by this change.
findepi
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.
This is really a nice chance!
Couple editorial comments
datafusion/expr/src/async_udf.rs
Outdated
| } | ||
|
|
||
| #[test] | ||
| fn udf_equality_and_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.
it's generally beneficial to test eq, hash and ord together, because their contracts are closely related
see existing test_partial_eq_hash_and_partial_ord for example
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.
I notice we don't have PartialOrd impl for AsyncScalarUDF; should we just copy the implementation from ScalarUDF and implement it 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.
No, let's not add it here.
Clearing a TODO item I noticed, since we're now MSRV of 1.87.0:
datafusion/Cargo.toml
Lines 78 to 79 in 3ee52f8
Utilize
dyn_eqanddyn_hashvia trait upcasting. There is a slight change in behaviour given the pointers inside the Arcs aren't being compared anymore, see comment.