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

Stamatis Zampetakis commented on CALCITE-7270:
----------------------------------------------

I am a bit skeptical to what extend we should attempt to emulate the division 
(or other similar) operator variants. Adding runtime support (in 
enumerable/bindable) for such operators could eventually lead to copy-pasting 
runtime code from other projects inside calcite core or linq4j and I am not 
really sure if that is the direction we want to go.

For instance, it would be nice to have a division operator with the Hive 
semantics in Calcite although I would probably target only parsing, validation, 
planning/rules, and not runtime. Trying to tackle runtime would mean that I 
have to come up with a copy/adapt of 
[GenericUDFOPDivide|https://github.com/apache/hive/blob/ca105f8124072d19d88a83b2ced613d326c9a26b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFOPDivide.java]
 that I would have to maintain in two projects.

 

> Add support for the DuckDB integer division operator //
> -------------------------------------------------------
>
>                 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