You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/02/05 11:04:40 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5179: Fix decimal scalar dyn kernels

alamb commented on code in PR #5179:
URL: https://github.com/apache/arrow-datafusion/pull/5179#discussion_r1096664517


##########
datafusion/physical-expr/src/expressions/binary.rs:
##########
@@ -1694,6 +1694,49 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn plus_op_dict_scalar_decimal() -> Result<()> {
+        let schema = Schema::new(vec![Field::new(
+            "a",
+            DataType::Dictionary(
+                Box::new(DataType::Int8),
+                Box::new(DataType::Decimal128(10, 0)),
+            ),
+            true,
+        )]);
+
+        let value = 123;
+        let decimal_array = Arc::new(create_decimal_array(
+            &[Some(value), None, Some(value - 1), Some(value + 1)],
+            10,
+            0,
+        )) as ArrayRef;
+
+        let keys = Int8Array::from(vec![0, 2, 1, 3, 0]);
+        let a = DictionaryArray::try_new(&keys, &decimal_array)?;
+
+        let keys = Int8Array::from(vec![0, 2, 1, 3, 0]);
+        let decimal_array = create_decimal_array(
+            &[Some(value + 1), None, Some(value), Some(value + 2)],
+            10,
+            0,
+        );
+        let expected = DictionaryArray::try_new(&keys, &decimal_array)?;
+
+        apply_arithmetic_scalar(
+            Arc::new(schema),
+            vec![Arc::new(a)],
+            Operator::Plus,
+            ScalarValue::Dictionary(
+                Box::new(DataType::Int8),
+                Box::new(ScalarValue::Decimal128(Some(1), 10, 0)),

Review Comment:
   without this PR's code, is the actual type of the output array whatever the default precision of `Decimal128` is (rather than `10, 0`)?



##########
.github/workflows/dev.yml:
##########
@@ -54,4 +54,5 @@ jobs:
             '!datafusion/CHANGELOG.md' \
             README.md \
             CONTRIBUTING.md
+          git config --global --add safe.directory "$GITHUB_WORKSPACE" 

Review Comment:
   I think this is no longer needed after updating to latest master



-- 
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