[ 
https://issues.apache.org/jira/browse/ARROW-14518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17436367#comment-17436367
 ] 

Kanstantsin Ilchanka commented on ARROW-14518:
----------------------------------------------

Problem here is that Arrow expects fixed scale for all array values as far as 
understand

So we will have a problem here, 
{code:java}
decimals = [
  BigDecimal("1.1"),
  BigDecimal("1.10"),
  BigDecimal("1.111"),
]
decimals.sum.to_s => "3.311"

Arrow::Decimal128ArrayBuilder.build(
  Arrow::Decimal128DataType.new(4, 3), decimals
).sum.to_s => "1.133"{code}
1.1 will be converted to 0.011 to scale to 3 digits after dot
1.10 is the same

Array of decimals should be validated to have the same scale, any other options?

 

> [Ruby] ArrayBuilder doesn't work correctly with Decimal
> -------------------------------------------------------
>
>                 Key: ARROW-14518
>                 URL: https://issues.apache.org/jira/browse/ARROW-14518
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Ruby
>            Reporter: Kanstantsin Ilchanka
>            Priority: Minor
>
> When trying to convert raw data with decimal values to Arrow::Table error 
> received
>  
> {code:java}
> Arrow::Table.new(x: [BigDecimal('1.1')])
> ArgumentError: wrong arguments: Arrow::Decimal128ArrayBuilder#initialize(): 
> available signatures: (data_type: 
> interface(Arrow::Decimal128DataType(GArrowDecimal128DataType)))
> {code}
> I guess this is because Decimal128ArrayBuilder expects Decimal128DataType in 
> initialiser, however I'm not sure how to correctly and effectively detect 
> precision and scale from array of BigDecimal
>  
> {code:java}
> Arrow::VERSION
> => "5.0.0"{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to