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

Mihai Budiu commented on CALCITE-7264:
--------------------------------------

As I said elsewhere I think that the DIV problem is really that there are two 
different operators, one safe and one unsafe, and the representation does not 
distinguish them.

Maybe the methods proposed here are useful, but I think that they should not be 
motivated by the DIV operator.

> New API for determining if an operator may throw
> ------------------------------------------------
>
>                 Key: CALCITE-7264
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7264
>             Project: Calcite
>          Issue Type: New Feature
>            Reporter: Thomas Rebele
>            Priority: Major
>
> The SQL standard defines that 1/0 throws an exception. Calcite follows the 
> standard here. However, some projects that use Calcite (e.g., Hive) define 
> the result of 1/0 as NULL. This may lead to different results in RexSimplify: 
> E.g., IS NULL(1/0) would throw for the SQL standard semantics, but would 
> return TRUE for the Hive semantics.
> RexSimplify handles this with a concept called "safe" defined in 
> [RexSimplify#isSafeExpression|https://github.com/apache/calcite/blob/34989b0ed7793cedf713c2f159de6247a730458c/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L1631].
>  The safe operators are defined in 
> [RexSimplify.SafeRexVisitor|https://github.com/apache/calcite/blob/34989b0ed7793cedf713c2f159de6247a730458c/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L1490].
>  The goal of this ticket is to make the behavior configurable. We can 
> continue to attach the safeness to the operators, so we could move the 
> safeOps set somewhere else. Here some examples:
>  * boolean RelDataTypeSystem#canOperatorThrow(SqlKind op)
>  * boolean RelDataTypeSystem#canOperatorThrow(SqlOperator op)
>  * boolean RelDataTypeSystem#isNoExceptOperator(...) //noexcept notion 
> borrowed from C++
>  * boolean RelDataTypeSystem#isSafeOperator
>  * Set<SqlKind> RelDataTypeSystem#noexceptOperators()
> The safeness information would be useful for other parts of the code as well, 
> e.g., CALCITE-5315.
> See the related discussions:
>  * 
> https://issues.apache.org/jira/browse/CALCITE-7145?focusedCommentId=18016030#comment-18016030
>  * [http://lists.apache.org/thread/cp7h28k1yfxv421q12y1wopbwgrzdzrx]



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

Reply via email to