Skip to content
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

Merged
merged 4 commits into from Jul 7, 2022
Merged

Conversation

viirya
Copy link
Member

@viirya viirya commented Jun 30, 2022

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?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Jun 30, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 30, 2022

Codecov Report

Merging #1983 (bff0fb5) into master (da3879e) will decrease coverage by 0.18%.
The diff coverage is 95.69%.

@@            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     
Impacted Files Coverage Δ
arrow/src/compute/kernels/arithmetic.rs 93.62% <95.69%> (+0.23%) ⬆️
parquet/src/arrow/array_reader/empty_array.rs 45.45% <0.00%> (-10.11%) ⬇️
parquet/src/arrow/array_reader/struct_array.rs 78.99% <0.00%> (-9.69%) ⬇️
parquet/src/arrow/array_reader/map_array.rs 58.82% <0.00%> (-8.98%) ⬇️
parquet/src/column/reader/decoder.rs 69.23% <0.00%> (-7.05%) ⬇️
parquet/src/arrow/array_reader/null_array.rs 81.48% <0.00%> (-6.52%) ⬇️
parquet/src/column/reader.rs 62.00% <0.00%> (-6.32%) ⬇️
parquet/src/arrow/record_reader/mod.rs 89.36% <0.00%> (-5.38%) ⬇️
parquet/src/arrow/arrow_reader.rs 92.40% <0.00%> (-4.47%) ⬇️
parquet/src/arrow/array_reader/test_util.rs 77.63% <0.00%> (-3.20%) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da3879e...bff0fb5. Read the comment docs.

@viirya
Copy link
Member Author

viirya commented Jun 30, 2022

The clippy errors seems not caused by this change. I will fix them separately if it is reproducible locally.

@viirya
Copy link
Member Author

viirya commented Jul 7, 2022

cc @sunchao This is more complicated.

Comment on lines +993 to +995
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),
Copy link
Member Author

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())
Copy link
Contributor

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

Copy link
Member Author

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>,
Copy link
Contributor

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

Copy link
Member Author

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>)
Copy link
Contributor

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?

Copy link
Member Author

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() {
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

@sunchao sunchao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@viirya
Copy link
Member Author

viirya commented Jul 7, 2022

Thanks @sunchao

@viirya viirya merged commit ef02bf8 into apache:master Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support DictionaryArray in divide kernel
3 participants