[ 
https://issues.apache.org/jira/browse/CALCITE-7270?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18042887#comment-18042887
 ] 

Julian Hyde commented on CALCITE-7270:
--------------------------------------

I would pick one operator (say DuckDB's integer division), write tests for it, 
and aim to emulate it exactly. If someone is running in (loosely) "DuckDB 
mode", then SqlToRelConverter would translate "/" applied to integers do the 
DUCKDB_INT_DIVIDE operator.

Rinse and repeat. Maybe MYSQL_INT_DIVIDE operator has exactly the same 
behavior, or maybe it differs in one regard (say when dividing by -1 causes 
integer overflow).

Your one operator, DUCKDB_INT_DIVIDE, provides a template that people can 
follow for the operators that they care about.

Pay special attention to tests. As I've said elsewhere, our inability to 
automatically run tests on a compliant DB is a weakness, because it forces us 
to manually write tests for each DB, and those tests are a mess. 

> Add support for a DIVIDE_0_NULL operation
> -----------------------------------------
>
>                 Key: CALCITE-7270
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7270
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.41.0
>            Reporter: Mihai Budiu
>            Priority: Minor
>              Labels: pull-request-available
>
> SQL dialects treat DIVISION in different ways: in some dialects division by 0 
> produces an exception, while in other dialects (e.q. sqlite) it produces NULL.
> These are really two different operators with the same name. I think they 
> should be represented by different operations in the IR: e.g., DIVIDE and 
> SAFE_DIVIDE.
> This is reminiscent to the CHECKED arithmetic operations introduced in 
> [CALCITE-6685], and the solution could be similar: in that issue whether an 
> ADD operation is checked or unchecked is a property of SqlConformance. 
> Similarly, we could add a boolean flag to SqlConformance indicating whether 
> division is safe or not and a visitor that will rewrite DIVIDE to SAFE_DIVIDE 
> when necessary.
> Spawn from [CALCITE-7145]
> I am happy to assign this to myself if people agree.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to