Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
Description
Casting from integer to decimal currently requires a precision of at least 12 (I think that might be the maximum precision required to represent any int32), irrespective of the actual values requiring casting.
An example of how this surfaces in R:
library(arrow) a <- as.double(1:10) b <- 1:10 typeof(a) #> [1] "double" typeof(b) #> [1] "integer" Array$create(a)$cast(decimal(4, 2)) #> Array #> <decimal128(4, 2)> #> [ #> 1.00, #> 2.00, #> 3.00, #> 4.00, #> 5.00, #> 6.00, #> 7.00, #> 8.00, #> 9.00, #> 10.00 #> ] # a precision of 4 should be more than enough for this example Array$create(b)$cast(decimal(4, 2)) #> Error: Invalid: Precision is not great enough for the result. It should be at least 12
Float to decimal casting checks each value instead of upfront. See here.