[
https://issues.apache.org/jira/browse/CALCITE-5591?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17730659#comment-17730659
]
Tanner Clary edited comment on CALCITE-5591 at 6/8/23 6:03 PM:
---------------------------------------------------------------
[~julianhyde][~FrankZou] Because of the type mapping between BigQuery and
Calcite (for example: {{TINYINT}}, {{SMALLINT}}, {{INTEGER}}, and {{BIGINT}}
all fall under BigQuery's {{INT64}}). This makes determining the correct
behavior in Calcite difficult because the overflow/underflow value for the
{{INT64}} type is actually equivalent to Java's {{LONG}} type (-2^63 and 2^63 -
1, respectively).
I was wondering whether either of you had ideas on how to make sure we are
covering all possible cases while still matching expected behavior. A more
specific question is: do there need to be entries/tests for things like
{{TINYINT}} etc if all integer types fall under BigQuery's {{INT64}} anyways?
For example, if I have two {{TINYINT}} values, and I multiply them s.t. their
result exceeds the {{TINYINT}} max value, should that return {{NULL}} even
though it did not exceed the {{LONG}} max value (aka BQ's {{INT64}}?
was (Author: JIRAUSER298151):
[~julianhyde][~FrankZou] Because of the type mapping between BigQuery and
Calcite (for example: {{TINYINT}}, {{SMALLINT}}, {{INTEGER}}, and {{BIGINT}}
all fall under BigQuery's {{INT64}}). This makes determining the correct
behavior in Calcite difficult because the overflow/underflow value for the
{{INT64}} type is actually equivalent to Java's {{LONG}} type (-2^63 and 2^63 -
1, respectively).
I was wondering whether either of you had ideas on how to make sure we are
covering all possible cases while still matching expected behavior. A more
specific question is: do there need to be entries/tests for things like
{{TINYINT}} etc if all integer types fall under BigQuery's {{INT64}} anyways?
> Implement BigQuery functions SAFE_ADD, SAFE_SUBTRACT, SAFE_MULTIPLY,
> SAFE_DIVIDE and SAFE_NEGATE
> ------------------------------------------------------------------------------------------------
>
> Key: CALCITE-5591
> URL: https://issues.apache.org/jira/browse/CALCITE-5591
> Project: Calcite
> Issue Type: New Feature
> Reporter: Dan Zou
> Assignee: Dan Zou
> Priority: Major
>
> Add support for SAFE_ADD, SAFE_SUBTRACT, SAFE_MULTIPLY, SAFE_DIVIDE and
> SAFE_NEGATE in BigQuery.
> Function description:
> * SAFE_ADD: Equivalent to the addition operator '+', but returns NULL if
> overflow occurs.
> * SAFE_SUBTRACT: Equivalent to the subtraction operator '-', but returns NULL
> if overflow occurs.
> * SAFE_MULTIPLY: Equivalent to the multiplication operator '*', but returns
> NULL if overflow occurs.
> * SAFE_DIVIDE: Equivalent to the division operator '/ ', but returns NULL if
> an error occurs, such as a division by zero error.
> * SAFE_NEGATE: Equivalent to the unary minus operator '-', but returns NULL
> if overflow occurs.
> See more details in [BigQuery
> Doc|https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#safe_divide]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)