tustvold commented on code in PR #2680:
URL: https://github.com/apache/arrow-datafusion/pull/2680#discussion_r888097956


##########
datafusion/sql/src/utils.rs:
##########
@@ -447,24 +447,16 @@ pub(crate) fn make_decimal_type(
     precision: Option<u64>,
     scale: Option<u64>,
 ) -> Result<DataType> {
-    match (precision, scale) {
-        (None, _) | (_, None) => {
-            return Err(DataFusionError::Internal(format!(
-                "Decimal(precision, scale) must both be specified, got ({:?}, 
{:?})",
-                precision, scale
-            )));
-        }
-        (Some(p), Some(s)) => {
-            // Arrow decimal is i128 meaning 38 maximum decimal digits
-            if (p as usize) > DECIMAL_MAX_PRECISION || s > p {
-                return Err(DataFusionError::Internal(format!(
-                    "For decimal(precision, scale) precision must be less than 
or equal to 38 and scale can't be greater than precision. Got ({}, {})",
-                    p, s
-                )));
-            } else {
-                Ok(DataType::Decimal(p as usize, s as usize))
-            }
-        }
+    let scale = scale.unwrap_or(DECIMAL_DEFAULT_SCALE as u64) as usize;

Review Comment:
   I'm not intimately familiar with the decimal type, but I can't see anywhere 
that would suggest precision + scale must equal 38. In fact 
https://arrow.apache.org/docs/python/generated/pyarrow.decimal128.html would 
seem to suggest that scale can be anything, much like a floating point exponent.



-- 
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-unsubscr...@arrow.apache.org

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

Reply via email to