[
https://issues.apache.org/jira/browse/CALCITE-6328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17826940#comment-17826940
]
Tanner Clary commented on CALCITE-6328:
---------------------------------------
Sounds good (y)
> The BigQuery functions SAFE_* do not match the BigQuery specification
> ---------------------------------------------------------------------
>
> Key: CALCITE-6328
> URL: https://issues.apache.org/jira/browse/CALCITE-6328
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.36.0
> Reporter: Mihai Budiu
> Priority: Minor
>
> The BigQuery dialect does not support DECIMAL values with arbitrary types: it
> only supports two fixed types: NUMERIC and BIGNUMERIC, both with fixed
> precision and scale.
> The runtime implementation of the SAFE_* functions uses the following helper
> in SqlFunctions:
> {code:java}
> /** Returns whether a BigDecimal value is safe (that is, has not
> overflowed).
> * According to BigQuery, BigDecimal overflow occurs if the precision is
> greater
> * than 76 or the scale is greater than 38. */
> private static boolean safeDecimal(BigDecimal b) {
> return b.scale() <= 38 && b.precision() <= 76;
> }
> {code}
> This helper does not handle correctly NUMERIC value, only BIGNUMERIC.
> Moreover, all the tests in SqlOperatorTests use a type system which doesn't
> even support DECIMAL values wider than 38 digits. So a test like the
> following:
> {code:java}
> f.checkNull("safe_add(cast(-9.9e75 as DECIMAL(76, 0)), "
> + "cast(-9.9e75 as DECIMAL(76, 0)))");
> {code}
> cannot even create the expected BigDecimal value correctly.
> This surfaced during the attempt to fix [CALCITE-6322]: once the casts to
> DECIMAL are implemented, some of these tests break.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)