-
Notifications
You must be signed in to change notification settings - Fork 1.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
Changes from 4 commits
0a33401
a9e8b67
066f2b1
1bf0384
635e90d
f9ab93f
219c131
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2032,10 +2032,10 @@ macro_rules! typed_compares { | |||||
|
|
||||||
| /// 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) => {{ | ||||||
| match ($LEFT.value_type(), $RIGHT.value_type()) { | ||||||
| (DataType::Boolean, DataType::Boolean) => { | ||||||
| cmp_dict_bool::<$KT, _>($LEFT, $RIGHT, $OP) | ||||||
| cmp_dict_bool::<$KT, _>($LEFT, $RIGHT, $OP_BOOL) | ||||||
| } | ||||||
| (DataType::Int8, DataType::Int8) => { | ||||||
| cmp_dict::<$KT, Int8Type, _>($LEFT, $RIGHT, $OP) | ||||||
|
|
@@ -2141,49 +2141,49 @@ macro_rules! typed_dict_cmp { | |||||
|
|
||||||
| macro_rules! typed_dict_compares { | ||||||
| // Applies `LEFT OP RIGHT` when `LEFT` and `RIGHT` both are `DictionaryArray` | ||||||
| ($LEFT: expr, $RIGHT: expr, $OP: expr) => {{ | ||||||
| ($LEFT: expr, $RIGHT: expr, $OP: expr, $OP_BOOL: expr) => {{ | ||||||
| match ($LEFT.data_type(), $RIGHT.data_type()) { | ||||||
| (DataType::Dictionary(left_key_type, _), DataType::Dictionary(right_key_type, _))=> { | ||||||
| match (left_key_type.as_ref(), right_key_type.as_ref()) { | ||||||
| (DataType::Int8, DataType::Int8) => { | ||||||
| let left = as_dictionary_array::<Int8Type>($LEFT); | ||||||
| let right = as_dictionary_array::<Int8Type>($RIGHT); | ||||||
| typed_dict_cmp!(left, right, $OP, Int8Type) | ||||||
| typed_dict_cmp!(left, right, $OP, $OP_BOOL, Int8Type) | ||||||
| } | ||||||
| (DataType::Int16, DataType::Int16) => { | ||||||
| let left = as_dictionary_array::<Int16Type>($LEFT); | ||||||
| let right = as_dictionary_array::<Int16Type>($RIGHT); | ||||||
| typed_dict_cmp!(left, right, $OP, Int16Type) | ||||||
| typed_dict_cmp!(left, right, $OP, $OP_BOOL, Int16Type) | ||||||
| } | ||||||
| (DataType::Int32, DataType::Int32) => { | ||||||
| let left = as_dictionary_array::<Int32Type>($LEFT); | ||||||
| let right = as_dictionary_array::<Int32Type>($RIGHT); | ||||||
| typed_dict_cmp!(left, right, $OP, Int32Type) | ||||||
| typed_dict_cmp!(left, right, $OP, $OP_BOOL, Int32Type) | ||||||
| } | ||||||
| (DataType::Int64, DataType::Int64) => { | ||||||
| let left = as_dictionary_array::<Int64Type>($LEFT); | ||||||
| let right = as_dictionary_array::<Int64Type>($RIGHT); | ||||||
| typed_dict_cmp!(left, right, $OP, Int64Type) | ||||||
| typed_dict_cmp!(left, right, $OP, $OP_BOOL, Int64Type) | ||||||
| } | ||||||
| (DataType::UInt8, DataType::UInt8) => { | ||||||
| let left = as_dictionary_array::<UInt8Type>($LEFT); | ||||||
| let right = as_dictionary_array::<UInt8Type>($RIGHT); | ||||||
| typed_dict_cmp!(left, right, $OP, UInt8Type) | ||||||
| typed_dict_cmp!(left, right, $OP, $OP_BOOL, UInt8Type) | ||||||
| } | ||||||
| (DataType::UInt16, DataType::UInt16) => { | ||||||
| let left = as_dictionary_array::<UInt16Type>($LEFT); | ||||||
| let right = as_dictionary_array::<UInt16Type>($RIGHT); | ||||||
| typed_dict_cmp!(left, right, $OP, UInt16Type) | ||||||
| typed_dict_cmp!(left, right, $OP, $OP_BOOL, UInt16Type) | ||||||
| } | ||||||
| (DataType::UInt32, DataType::UInt32) => { | ||||||
| let left = as_dictionary_array::<UInt32Type>($LEFT); | ||||||
| let right = as_dictionary_array::<UInt32Type>($RIGHT); | ||||||
| typed_dict_cmp!(left, right, $OP, UInt32Type) | ||||||
| typed_dict_cmp!(left, right, $OP, $OP_BOOL, UInt32Type) | ||||||
| } | ||||||
| (DataType::UInt64, DataType::UInt64) => { | ||||||
| let left = as_dictionary_array::<UInt64Type>($LEFT); | ||||||
| let right = as_dictionary_array::<UInt64Type>($RIGHT); | ||||||
| typed_dict_cmp!(left, right, $OP, UInt64Type) | ||||||
| typed_dict_cmp!(left, right, $OP, $OP_BOOL, UInt64Type) | ||||||
| } | ||||||
| (t1, t2) if t1 == t2 => Err(ArrowError::NotYetImplemented(format!( | ||||||
| "Comparing dictionary arrays of type {} is not yet implemented", | ||||||
|
|
@@ -2318,7 +2318,7 @@ where | |||||
| pub fn eq_dyn(left: &dyn Array, right: &dyn Array) -> Result<BooleanArray> { | ||||||
| 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)) | ||||||
|
||||||
| 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
Outdated
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) |
Outdated
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) |
Outdated
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) |
Outdated
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) |
Outdated
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) |
Outdated
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()); |
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