viirya commented on code in PR #5179:
URL: https://github.com/apache/arrow-datafusion/pull/5179#discussion_r1096767895
##########
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:
No, original code still modifies precision/scale for output array, but it
just works for primitive array not dictionary array.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]