You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Hezhiqiang (Ransom)" <ra...@huawei.com> on 2017/05/08 12:25:35 UTC
Range of decimal type in Calcite
Hi all.
What's the range of decimal data type in calcite?
In SqlValidatorImpl. validateLiteral method , decimal range validate. It used a long value to validate it .
Is it means decimal type max value in calcite is 922337203685477580.7
And the min value in calcite is -922337203685477580.8
And the scale value is 0.9223372036854775807
How to create a decimal literal like 99999999999999999999999999.999999999999 ?
Regards
Ransom
Re: Range of decimal type in Calcite
Posted by Julian Hyde <jh...@apache.org>.
I think the current implementation is wrong. The validation should check against RelDataTypeSystem.getMaxPrecision(SqlTypeName.DECIMAL). And since that precision might be larger than allowed by a Java long, it follows that the SqlValidatorImpl.validateLiteral should not be converting to long. It should keep the value as a BigDecimal.
Now, if you use a RelDataTypeSystem that allows very large-precision DECIMAL values, then of course you then need to implement them… but that’s your problem, not ours. :)
Can you log a JIRA case please.
Julian
> On May 8, 2017, at 5:25 AM, Hezhiqiang (Ransom) <ra...@huawei.com> wrote:
>
> Hi all.
> What’s the range of decimal data type in calcite?
> In SqlValidatorImpl. validateLiteral method , decimal range validate. It used a long value to validate it .
> Is it means decimal type max value in calcite is 922337203685477580.7
> And the min value in calcite is -922337203685477580.8
> And the scale value is 0.9223372036854775807
> How to create a decimal literal like 99999999999999999999999999.999999999999 ?
>
>
> Regards
> Ransom