junjunjd commented on code in PR #7901:
URL: https://github.com/apache/arrow-datafusion/pull/7901#discussion_r1381174929


##########
datafusion/common/src/scalar.rs:
##########
@@ -1748,17 +1797,17 @@ impl ScalarValue {
         precision: u8,
         scale: i8,
         size: usize,
-    ) -> Decimal128Array {
+    ) -> Result<Decimal128Array> {
         match value {
             Some(val) => Decimal128Array::from(vec![val; size])
                 .with_precision_and_scale(precision, scale)
-                .unwrap(),

Review Comment:
   Since 
[`ScalarValue::try_new_decimal128`](https://github.com/apache/arrow-datafusion/blob/main/datafusion/common/src/scalar.rs#L660-L661)
 allows a decimal with precision 0, this error is reachable when user creates a 
decimal with precision 0 and 
[`arrow-array`](https://github.com/apache/arrow-rs/blob/master/arrow-array/src/types.rs#L1234-L1235)
 does not support 0 precision decimal.
   Would it make sense to disallow a decimal with precision 0 in 
`try_new_decimal128` so that this error becomes unreachable?



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

Reply via email to