Implement DictionaryArray support in neq_dyn, lt_dyn, lt_eq_dyn, gt_dyn, gt_eq_dyn#1326
Implement DictionaryArray support in neq_dyn, lt_dyn, lt_eq_dyn, gt_dyn, gt_eq_dyn#1326alamb merged 7 commits intoapache:masterfrom
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 |
| /// 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.
👍 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.
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.
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.
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.
| 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.
| 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.
| 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.
| 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.
| 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.
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 |
|
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?