[ https://issues.apache.org/jira/browse/ARROW-17601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17599604#comment-17599604 ]
Neal Richardson commented on ARROW-17601: ----------------------------------------- Here's a reproducer just using Expressions, no dplyr: {code} expr <- Expression$create("multiply_checked", Expression$field_ref("col1"), Expression$field_ref("col2")) expr # Expression # multiply_checked(col1, col2) expr$type(schema(col1=decimal128(33, 4), col2=decimal128(15, 2))) # Error: Invalid: Decimal precision out of range [1, 38]: 49 {code} Note that the different kernels have different promotion logic. Subtraction, for example, doesn't go out of range with these types. {code} expr <- Expression$create("subtract_checked", Expression$field_ref("col1"), Expression$field_ref("col2")) expr$type(schema(col1=decimal128(33, 4), col2=decimal128(15, 2))) # Decimal128Type # decimal128(34, 4) {code} > [C++] Error when creating Expression on Decimal128 types: precision out of > range > -------------------------------------------------------------------------------- > > Key: ARROW-17601 > URL: https://issues.apache.org/jira/browse/ARROW-17601 > Project: Apache Arrow > Issue Type: Bug > Components: C++ > Reporter: Neal Richardson > Priority: Major > > Reproducer in R: > {code} > library(arrow) > library(dplyr) > tab <- Table$create(col1 = 1:4, col2 = 5:8) > tab <- tab$cast(schema(col1 = decimal128(33, 4), col2 = decimal128(15, 2))) > tab %>% mutate(col1 * col2) > # Error: Invalid: Decimal precision out of range [1, 38]: 49 > # /Users/me/arrow/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc:1078 > DecimalType::Make(left_type.id(), precision, scale) > # /Users/me/arrow/cpp/src/arrow/compute/exec/expression.cc:413 > call.kernel->signature->out_type().Resolve(&kernel_context, types) > {code} > With integers and floats, we upcast to a wider size in some compute functions > like multiplication. Should this go up to Decimal256? Or is there a better > way to determine the size required? -- This message was sent by Atlassian Jira (v8.20.10#820010)