You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2023/09/07 22:08:00 UTC
[jira] [Commented] (CALCITE-5983) Add DIV and IEEE_DIVIDE functions (enabled in BigQuery library)
[ https://issues.apache.org/jira/browse/CALCITE-5983?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17762886#comment-17762886 ]
Julian Hyde commented on CALCITE-5983:
--------------------------------------
I don’t know whether IEEE values Infinity, NaN, etc. are valid values of the DOUBLE SQL data type. Can you make sure that there are tests for basic operations on them - converting them to strings, from strings, to integers, etc.
Do any dialects of SQL allow them as literals? E.g. {{DOUBLE ‘infinity’}} is the kind of thing that Postgres might support.
If this stuff is non-trivial, feel free to cleave off a new jira case. Or maybe it’s already done and I’ve missed it.
> Add DIV and IEEE_DIVIDE functions (enabled in BigQuery library)
> ---------------------------------------------------------------
>
> Key: CALCITE-5983
> URL: https://issues.apache.org/jira/browse/CALCITE-5983
> Project: Calcite
> Issue Type: Improvement
> Reporter: Tanner Clary
> Assignee: Tanner Clary
> Priority: Major
>
> BigQuery offers the DIV function ([docs|https://cloud.google.com/bigquery/docs/reference/standard-sql/mathematical_functions#div]) and the IEEE_DIVIDE function ([docs|https://cloud.google.com/bigquery/docs/reference/standard-sql/mathematical_functions#ieee_divide]).
> The {{DIV(x, y)}} function returns the result of integer division of X by Y. Division by zero returns an error. Division by -1 may overflow.
> The {{IEEE_DIVIDE(x, y)}} function divides X by Y; this function never fails. Returns Double. Unlike the division operator (/), this function does not generate errors for division by zero or overflow.
> {{DIV}} examples:
> 1. {{DIV(20, 4)}} should return {{5}}.
> 2. {{DIV(2.5, 1)}} should return {{2}} because the result is floored to the nearest integer.
> 3. {{DIV(20, 0)}} should throw an error like: {{Division by zero}}.
> {{IEEE_DIVIDE}} examples:
> 1. {{DIV(20, 4)}} should return {{5.0}}.
> 2. {{DIV(20, 0)}} should return {{Infinity}}.
> 3. {{DIV(0, 0)}} should return {{NaN}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)