-
Notifications
You must be signed in to change notification settings - Fork 839
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
Support dictionary array for divide kernel #1983
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1983 +/- ##
==========================================
- Coverage 83.62% 83.43% -0.19%
==========================================
Files 222 222
Lines 57763 57979 +216
==========================================
+ Hits 48304 48375 +71
- Misses 9459 9604 +145
Continue to review full report at Codecov.
|
The clippy errors seems not caused by this change. I will fix them separately if it is reproducible locally. |
cc @sunchao This is more complicated. |
typed_dict_math_op!(left, right, |a, b| a / b, math_divide_checked_op_dict) | ||
} | ||
_ => typed_math_op!(left, right, |a, b| a / b, math_checked_divide_op), |
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 extracted the called op function as a parameter.
}, | ||
); | ||
} else { | ||
Ok(T::default_value()) |
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.
curious why we are using default value here
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 follows the divide kernel did before. I think for the case (left or right is None), the value is not important, so it just put a default value there.
right: impl Iterator<Item = Option<T::Native>>, | ||
op: F, | ||
len: usize, | ||
null_bit_buffer: Option<Buffer>, |
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.
nit: maybe we can just pass a boolean flag here
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.
We still need null_bit_buffer
.
T::Native: One + Zero, | ||
F: Fn(T::Native, T::Native) -> T::Native, | ||
{ | ||
math_dict_divide_checked_op!(left, right, op, PrimitiveArray<T>) |
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.
why we need a macro for this? can we just inline it?
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.
okay, inlined it.
/// then the result is also null. If any right hand value is zero then the result of this | ||
/// operation will be `Err(ArrowError::DivideByZero)`. | ||
pub fn divide_dyn(left: &dyn Array, right: &dyn Array) -> Result<ArrayRef> { | ||
match left.data_type() { |
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.
what if right is not a dictionary? are we going to support it too?
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.
Yea, I will implement these supports later.
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.
LGTM
Thanks @sunchao |
Which issue does this PR close?
Closes #1982.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?