You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Kenta Murata (Jira)" <ji...@apache.org> on 2021/10/30 17:39:00 UTC
[jira] [Comment Edited] (ARROW-14518) [Ruby] ArrayBuilder doesn't
work correctly with Decimal
[ https://issues.apache.org/jira/browse/ARROW-14518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17436352#comment-17436352 ]
Kenta Murata edited comment on ARROW-14518 at 10/30/21, 5:38 PM:
-----------------------------------------------------------------
A {{BigDecimal}} number manages only its precision in its decimal notation.
We can get the precision of a {{BigDecimal}} number by {{BigDecimal#precision}} method.
{{irb(main):001:0> BigDecimal("1.1").precision}}
{{=> 2}}
But, the {{BigDecimal#precision}} method does not count the trailing zeros.
{{irb(main):002:0> BigDecimal("1.10").precision}}
{{=> 2}}
The reason why a {{BigDecimal}} number doesn't have the scale property may be a {{BigDecimal}} number isn't a fixed-precision number.
was (Author: mrkn):
A {{BigDecimal}} number manages only its precision in its decimal notation.
We can get the precision of a {{BigDecimal}} number by {{BigDecimal#precision}} method.
{{irb(main):001:0> BigDecimal("1.1").precision}}
{{=> 2}}
But, a {{BigDecimal#precision}} does not count the trailing zeros.
{{irb(main):002:0> BigDecimal("1.10").precision}}
{{=> 2}}
The reason why a {{BigDecimal}} number doesn't have the scale property may be a {{BigDecimal}} number isn't a fixed-precision number.
> [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)