- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1k
Implement DictionaryArray support in neq_dyn, lt_dyn, lt_eq_dyn, gt_dyn, gt_eq_dyn #1326
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
| Codecov Report
 @@            Coverage Diff             @@
##           master    #1326      +/-   ##
==========================================
+ Coverage   83.00%   83.04%   +0.04%     
==========================================
  Files         180      180              
  Lines       52919    52980      +61     
==========================================
+ Hits        43924    43998      +74     
+ Misses       8995     8982      -13     
 Continue to review full report at Codecov. 
 | 
| cc @alamb | 
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 @viirya -- this is looking great 😍
My only real concern is about using !(a^b) rather than a == b but I may be missing something
I went through the tests carefully and they look good to me. epic work
| /// Applies $OP to $LEFT and $RIGHT which are two dictionaries which have (the same) key type $KT | ||
| macro_rules! typed_dict_cmp { | ||
| ($LEFT: expr, $RIGHT: expr, $OP: expr, $KT: tt) => {{ | ||
| ($LEFT: expr, $RIGHT: expr, $OP: expr, $OP_BOOL: expr, $KT: tt) => {{ | 
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.
👍 nice readability improvement
| match left.data_type() { | ||
| DataType::Dictionary(_, _) => { | ||
| typed_dict_compares!(left, right, |a, b| a == b) | ||
| typed_dict_compares!(left, right, |a, b| a == b, |a, b| !(a ^ 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.
I don't understand this change -- I think the a == b is easier to understand and I would expect that llvm would create optimized code for whatever was being compared.
If this is clippy being silly about comparing booleans perhaps we can just ignore the lint
| typed_dict_compares!(left, right, |a, b| a == b, |a, b| !(a ^ b)) | |
| typed_dict_compares!(left, right, |a, b| a == b, |a, b| a == 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.
Oh, okay, I wrote it like you suggest at first, but changed it basically to make clippy happy. 😄
If we can ignore that, then I can change back.
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 think we can ignore it. I think clippy is somewhat confused probably when the parameters are boolean
| typed_compares!(left, right, neq_bool, neq, neq_utf8, neq_binary) | ||
| match left.data_type() { | ||
| DataType::Dictionary(_, _) => { | ||
| typed_dict_compares!(left, right, |a, b| a != b, |a, b| (a ^ 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.
| typed_dict_compares!(left, right, |a, b| a != b, |a, b| (a ^ b)) | |
| typed_dict_compares!(left, right, |a, b| a != b, |a, b| a != b) | 
| typed_compares!(left, right, lt_bool, lt, lt_utf8, lt_binary) | ||
| match left.data_type() { | ||
| DataType::Dictionary(_, _) => { | ||
| typed_dict_compares!(left, right, |a, b| a < b, |a, b| (!a) & 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.
| typed_dict_compares!(left, right, |a, b| a < b, |a, b| (!a) & b) | |
| typed_dict_compares!(left, right, |a, b| a < b, |a, b| a < b) | 
| typed_compares!(left, right, lt_eq_bool, lt_eq, lt_eq_utf8, lt_eq_binary) | ||
| match left.data_type() { | ||
| DataType::Dictionary(_, _) => { | ||
| typed_dict_compares!(left, right, |a, b| a <= b, |a, b| !(a & (!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.
| typed_dict_compares!(left, right, |a, b| a <= b, |a, b| !(a & (!b))) | |
| typed_dict_compares!(left, right, |a, b| a <= b, |a, b| a <= b) | 
| typed_compares!(left, right, gt_bool, gt, gt_utf8, gt_binary) | ||
| match left.data_type() { | ||
| DataType::Dictionary(_, _) => { | ||
| typed_dict_compares!(left, right, |a, b| a > b, |a, b| a & (!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.
| typed_dict_compares!(left, right, |a, b| a > b, |a, b| a & (!b)) | |
| typed_dict_compares!(left, right, |a, b| a > b, |a, b| a > b) | 
| typed_compares!(left, right, gt_eq_bool, gt_eq, gt_eq_utf8, gt_eq_binary) | ||
| match left.data_type() { | ||
| DataType::Dictionary(_, _) => { | ||
| typed_dict_compares!(left, right, |a, b| a >= b, |a, b| !((!a) & 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.
| typed_dict_compares!(left, right, |a, b| a >= b, |a, b| !((!a) & b)) | |
| typed_dict_compares!(left, right, |a, b| a >= b, |a, b| a >= b) | 
| ); | ||
|  | ||
| let result = neq_dyn(&dict_array1, &dict_array2); | ||
| assert!(result.is_ok()); | 
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.
As a style thing, I think it is ok to just .unwrap() the result -- if there is a problem it will panic one line later, but I think the source of the problem would still be quite clear
| assert!(result.is_ok()); | 
| Oh, I used  | 
| Thanks @alamb ! Changed the bool ops back and removed  | 
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.
Looking good @viirya 👌
| Hi @viirya -- I hope you don't mind but i merged this PR from master and added 219c131 to silence clippy -- it was claiming Which is nonsense in my opinion (!a & b) is much less readable than  | 
| Yea, no problem at all! Thanks @alamb ! | 
Which issue does this PR close?
Closes #1201.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?