You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/30 22:33:29 UTC

[GitHub] [arrow-rs] viirya opened a new pull request, #1983: Support dictionary array for divide kernel

viirya opened a new pull request, #1983:
URL: https://github.com/apache/arrow-rs/pull/1983

   # Which issue does this PR close?
   
   <!---
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #1982.
   
   # Rationale for this change
    
    <!---
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   # What changes are included in this PR?
   
   <!---
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   
   
   <!---
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking change` label.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] codecov-commenter commented on pull request #1983: Support dictionary array for divide kernel

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #1983:
URL: https://github.com/apache/arrow-rs/pull/1983#issuecomment-1171751430

   # [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/1983?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1983](https://codecov.io/gh/apache/arrow-rs/pull/1983?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ae6f892) into [master](https://codecov.io/gh/apache/arrow-rs/commit/a89c1cf58161473b162fe1251d1da4cd09b25e36?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a89c1cf) will **increase** coverage by `0.03%`.
   > The diff coverage is `98.75%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #1983      +/-   ##
   ==========================================
   + Coverage   83.56%   83.59%   +0.03%     
   ==========================================
     Files         221      221              
     Lines       57475    57544      +69     
   ==========================================
   + Hits        48029    48105      +76     
   + Misses       9446     9439       -7     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/arrow-rs/pull/1983?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [arrow/src/compute/kernels/arithmetic.rs](https://codecov.io/gh/apache/arrow-rs/pull/1983/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2NvbXB1dGUva2VybmVscy9hcml0aG1ldGljLnJz) | `92.72% <98.75%> (+0.79%)` | :arrow_up: |
   | [parquet\_derive/src/parquet\_field.rs](https://codecov.io/gh/apache/arrow-rs/pull/1983/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldF9kZXJpdmUvc3JjL3BhcnF1ZXRfZmllbGQucnM=) | `65.75% <0.00%> (-0.23%)` | :arrow_down: |
   | [arrow/src/datatypes/mod.rs](https://codecov.io/gh/apache/arrow-rs/pull/1983/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2RhdGF0eXBlcy9tb2QucnM=) | `99.24% <0.00%> (+<0.01%)` | :arrow_up: |
   | [parquet/src/arrow/schema.rs](https://codecov.io/gh/apache/arrow-rs/pull/1983/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvYXJyb3cvc2NoZW1hLnJz) | `96.88% <0.00%> (+<0.01%)` | :arrow_up: |
   | [arrow/src/compute/kernels/boolean.rs](https://codecov.io/gh/apache/arrow-rs/pull/1983/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2NvbXB1dGUva2VybmVscy9ib29sZWFuLnJz) | `96.80% <0.00%> (+<0.01%)` | :arrow_up: |
   | [arrow/src/compute/util.rs](https://codecov.io/gh/apache/arrow-rs/pull/1983/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2NvbXB1dGUvdXRpbC5ycw==) | `99.11% <0.00%> (+<0.01%)` | :arrow_up: |
   | [arrow/src/ipc/convert.rs](https://codecov.io/gh/apache/arrow-rs/pull/1983/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2lwYy9jb252ZXJ0LnJz) | `95.57% <0.00%> (+<0.01%)` | :arrow_up: |
   | [parquet/src/file/writer.rs](https://codecov.io/gh/apache/arrow-rs/pull/1983/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGFycXVldC9zcmMvZmlsZS93cml0ZXIucnM=) | `92.60% <0.00%> (+0.01%)` | :arrow_up: |
   | [arrow/src/datatypes/datatype.rs](https://codecov.io/gh/apache/arrow-rs/pull/1983/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YXJyb3cvc3JjL2RhdGF0eXBlcy9kYXRhdHlwZS5ycw==) | `65.79% <0.00%> (+0.37%)` | :arrow_up: |
   | ... and [4 more](https://codecov.io/gh/apache/arrow-rs/pull/1983/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/arrow-rs/pull/1983?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/arrow-rs/pull/1983?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a89c1cf...ae6f892](https://codecov.io/gh/apache/arrow-rs/pull/1983?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on a diff in pull request #1983: Support dictionary array for divide kernel

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #1983:
URL: https://github.com/apache/arrow-rs/pull/1983#discussion_r916223279


##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -126,44 +126,68 @@ where
     let null_bit_buffer =
         combine_option_bitmap(&[left.data_ref(), right.data_ref()], left.len())?;
 
-    let buffer = if let Some(b) = &null_bit_buffer {
-        let values = left.values().iter().zip(right.values()).enumerate().map(
-            |(i, (left, right))| {
-                let is_valid = unsafe { bit_util::get_bit_raw(b.as_ptr(), i) };
-                if is_valid {
-                    if right.is_zero() {
-                        Err(ArrowError::DivideByZero)
-                    } else {
-                        Ok(op(*left, *right))
-                    }
+    math_checked_divide_op_on_iters(
+        left.into_iter(),
+        right.into_iter(),
+        op,
+        left.len(),
+        null_bit_buffer,
+    )
+}
+
+/// Helper function for operations where a valid `0` on the right array should
+/// result in an [ArrowError::DivideByZero], namely the division and modulo operations
+///
+/// # Errors
+///
+/// This function errors if:
+/// * the arrays have different lengths
+/// * there is an element where both left and right values are valid and the right value is `0`
+fn math_checked_divide_op_on_iters<T, F>(
+    left: impl Iterator<Item = Option<T::Native>>,
+    right: impl Iterator<Item = Option<T::Native>>,
+    op: F,
+    len: usize,
+    null_bit_buffer: Option<Buffer>,
+) -> Result<PrimitiveArray<T>>
+where
+    T: ArrowNumericType,
+    T::Native: One + Zero,
+    F: Fn(T::Native, T::Native) -> T::Native,
+{
+    let buffer = if null_bit_buffer.is_some() {
+        let values = left.zip(right).map(|(left, right)| {
+            if let (Some(l), Some(r)) = (left, right) {
+                if r.is_zero() {
+                    Err(ArrowError::DivideByZero)
                 } else {
-                    Ok(T::default_value())
+                    Ok(op(l, r))
                 }
-            },
-        );
+            } else {
+                Ok(T::default_value())

Review Comment:
   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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on a diff in pull request #1983: Support dictionary array for divide kernel

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #1983:
URL: https://github.com/apache/arrow-rs/pull/1983#discussion_r916213612


##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -892,6 +984,18 @@ where
     return math_checked_divide_op(left, right, |a, b| a / b);
 }
 
+/// Perform `left / right` operation on two arrays. If either left or right value is null
+/// 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() {

Review Comment:
   Yea, I will implement these supports later.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] sunchao commented on a diff in pull request #1983: Support dictionary array for divide kernel

Posted by GitBox <gi...@apache.org>.
sunchao commented on code in PR #1983:
URL: https://github.com/apache/arrow-rs/pull/1983#discussion_r916178915


##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -126,44 +126,68 @@ where
     let null_bit_buffer =
         combine_option_bitmap(&[left.data_ref(), right.data_ref()], left.len())?;
 
-    let buffer = if let Some(b) = &null_bit_buffer {
-        let values = left.values().iter().zip(right.values()).enumerate().map(
-            |(i, (left, right))| {
-                let is_valid = unsafe { bit_util::get_bit_raw(b.as_ptr(), i) };
-                if is_valid {
-                    if right.is_zero() {
-                        Err(ArrowError::DivideByZero)
-                    } else {
-                        Ok(op(*left, *right))
-                    }
+    math_checked_divide_op_on_iters(
+        left.into_iter(),
+        right.into_iter(),
+        op,
+        left.len(),
+        null_bit_buffer,
+    )
+}
+
+/// Helper function for operations where a valid `0` on the right array should
+/// result in an [ArrowError::DivideByZero], namely the division and modulo operations
+///
+/// # Errors
+///
+/// This function errors if:
+/// * the arrays have different lengths
+/// * there is an element where both left and right values are valid and the right value is `0`
+fn math_checked_divide_op_on_iters<T, F>(
+    left: impl Iterator<Item = Option<T::Native>>,
+    right: impl Iterator<Item = Option<T::Native>>,
+    op: F,
+    len: usize,
+    null_bit_buffer: Option<Buffer>,
+) -> Result<PrimitiveArray<T>>
+where
+    T: ArrowNumericType,
+    T::Native: One + Zero,
+    F: Fn(T::Native, T::Native) -> T::Native,
+{
+    let buffer = if null_bit_buffer.is_some() {
+        let values = left.zip(right).map(|(left, right)| {
+            if let (Some(l), Some(r)) = (left, right) {
+                if r.is_zero() {
+                    Err(ArrowError::DivideByZero)
                 } else {
-                    Ok(T::default_value())
+                    Ok(op(l, r))
                 }
-            },
-        );
+            } else {
+                Ok(T::default_value())

Review Comment:
   curious why we are using default value here



##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -126,44 +126,68 @@ where
     let null_bit_buffer =
         combine_option_bitmap(&[left.data_ref(), right.data_ref()], left.len())?;
 
-    let buffer = if let Some(b) = &null_bit_buffer {
-        let values = left.values().iter().zip(right.values()).enumerate().map(
-            |(i, (left, right))| {
-                let is_valid = unsafe { bit_util::get_bit_raw(b.as_ptr(), i) };
-                if is_valid {
-                    if right.is_zero() {
-                        Err(ArrowError::DivideByZero)
-                    } else {
-                        Ok(op(*left, *right))
-                    }
+    math_checked_divide_op_on_iters(
+        left.into_iter(),
+        right.into_iter(),
+        op,
+        left.len(),
+        null_bit_buffer,
+    )
+}
+
+/// Helper function for operations where a valid `0` on the right array should
+/// result in an [ArrowError::DivideByZero], namely the division and modulo operations
+///
+/// # Errors
+///
+/// This function errors if:
+/// * the arrays have different lengths
+/// * there is an element where both left and right values are valid and the right value is `0`
+fn math_checked_divide_op_on_iters<T, F>(
+    left: impl Iterator<Item = Option<T::Native>>,
+    right: impl Iterator<Item = Option<T::Native>>,
+    op: F,
+    len: usize,
+    null_bit_buffer: Option<Buffer>,

Review Comment:
   nit: maybe we can just pass a boolean flag here



##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -671,6 +741,28 @@ where
     math_dict_op!(left, right, op, PrimitiveArray<T>)
 }
 
+/// Helper function for operations where a valid `0` on the right array should
+/// result in an [ArrowError::DivideByZero], namely the division and modulo operations
+///
+/// # Errors
+///
+/// This function errors if:
+/// * the arrays have different lengths
+/// * there is an element where both left and right values are valid and the right value is `0`
+fn math_divide_checked_op_dict<K, T, F>(
+    left: &DictionaryArray<K>,
+    right: &DictionaryArray<K>,
+    op: F,
+) -> Result<PrimitiveArray<T>>
+where
+    K: ArrowNumericType,
+    T: ArrowNumericType,
+    T::Native: One + Zero,
+    F: Fn(T::Native, T::Native) -> T::Native,
+{
+    math_dict_divide_checked_op!(left, right, op, PrimitiveArray<T>)

Review Comment:
   why we need a macro for this? can we just inline it?



##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -892,6 +984,18 @@ where
     return math_checked_divide_op(left, right, |a, b| a / b);
 }
 
+/// Perform `left / right` operation on two arrays. If either left or right value is null
+/// 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() {

Review Comment:
   what if right is not a dictionary? are we going to support it too?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on pull request #1983: Support dictionary array for divide kernel

Posted by GitBox <gi...@apache.org>.
viirya commented on PR #1983:
URL: https://github.com/apache/arrow-rs/pull/1983#issuecomment-1171769432

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on pull request #1983: Support dictionary array for divide kernel

Posted by GitBox <gi...@apache.org>.
viirya commented on PR #1983:
URL: https://github.com/apache/arrow-rs/pull/1983#issuecomment-1178270031

   Thanks @sunchao 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on a diff in pull request #1983: Support dictionary array for divide kernel

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #1983:
URL: https://github.com/apache/arrow-rs/pull/1983#discussion_r916221216


##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -671,6 +741,28 @@ where
     math_dict_op!(left, right, op, PrimitiveArray<T>)
 }
 
+/// Helper function for operations where a valid `0` on the right array should
+/// result in an [ArrowError::DivideByZero], namely the division and modulo operations
+///
+/// # Errors
+///
+/// This function errors if:
+/// * the arrays have different lengths
+/// * there is an element where both left and right values are valid and the right value is `0`
+fn math_divide_checked_op_dict<K, T, F>(
+    left: &DictionaryArray<K>,
+    right: &DictionaryArray<K>,
+    op: F,
+) -> Result<PrimitiveArray<T>>
+where
+    K: ArrowNumericType,
+    T: ArrowNumericType,
+    T::Native: One + Zero,
+    F: Fn(T::Native, T::Native) -> T::Native,
+{
+    math_dict_divide_checked_op!(left, right, op, PrimitiveArray<T>)

Review Comment:
   okay, inlined it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on pull request #1983: Support dictionary array for divide kernel

Posted by GitBox <gi...@apache.org>.
viirya commented on PR #1983:
URL: https://github.com/apache/arrow-rs/pull/1983#issuecomment-1177201144

   cc @sunchao This is more complicated.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya merged pull request #1983: Support dictionary array for divide kernel

Posted by GitBox <gi...@apache.org>.
viirya merged PR #1983:
URL: https://github.com/apache/arrow-rs/pull/1983


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on a diff in pull request #1983: Support dictionary array for divide kernel

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #1983:
URL: https://github.com/apache/arrow-rs/pull/1983#discussion_r916224503


##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -126,44 +126,68 @@ where
     let null_bit_buffer =
         combine_option_bitmap(&[left.data_ref(), right.data_ref()], left.len())?;
 
-    let buffer = if let Some(b) = &null_bit_buffer {
-        let values = left.values().iter().zip(right.values()).enumerate().map(
-            |(i, (left, right))| {
-                let is_valid = unsafe { bit_util::get_bit_raw(b.as_ptr(), i) };
-                if is_valid {
-                    if right.is_zero() {
-                        Err(ArrowError::DivideByZero)
-                    } else {
-                        Ok(op(*left, *right))
-                    }
+    math_checked_divide_op_on_iters(
+        left.into_iter(),
+        right.into_iter(),
+        op,
+        left.len(),
+        null_bit_buffer,
+    )
+}
+
+/// Helper function for operations where a valid `0` on the right array should
+/// result in an [ArrowError::DivideByZero], namely the division and modulo operations
+///
+/// # Errors
+///
+/// This function errors if:
+/// * the arrays have different lengths
+/// * there is an element where both left and right values are valid and the right value is `0`
+fn math_checked_divide_op_on_iters<T, F>(
+    left: impl Iterator<Item = Option<T::Native>>,
+    right: impl Iterator<Item = Option<T::Native>>,
+    op: F,
+    len: usize,
+    null_bit_buffer: Option<Buffer>,

Review Comment:
   We still need `null_bit_buffer`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] viirya commented on a diff in pull request #1983: Support dictionary array for divide kernel

Posted by GitBox <gi...@apache.org>.
viirya commented on code in PR #1983:
URL: https://github.com/apache/arrow-rs/pull/1983#discussion_r915559201


##########
arrow/src/compute/kernels/arithmetic.rs:
##########
@@ -892,6 +984,18 @@ where
     return math_checked_divide_op(left, right, |a, b| a / b);
 }
 
+/// Perform `left / right` operation on two arrays. If either left or right value is null
+/// 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() {
+        DataType::Dictionary(_, _) => {
+            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),

Review Comment:
   I extracted the called op function as a parameter.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org