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

Julian Hyde commented on CALCITE-7264:
--------------------------------------

I don’t think RexSafeVisiitor id the way to go. It should be metadata attached 
to the operator. isSafeOperator seems like a good start, but doesn’t take the 
arguments of the call into account. 



How about an interface Safety that an operator may or may not provide? If it 
doesn’t provide it, it is assumed safe (never throws). If it does provide it, 
there is a method on Safety that says, for a given set of arguments, which 
exception is thrown and whether it is definite or just possible. 

isSafeOperator can remain, but its implementation would just check whether 
Safety is null. 

> New API for determining if the evaluation of a RexNode 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. The API would 
> need to provide a method that accepts at least RexCall nodes. Maybe a more 
> general approach is favorable, e.g., {{{}isSafeExpression(RexNode r){}}}.
> This ticket aims to provide a refinement of 
> {{{}org.apache.calcite.sql.SqlOperator#isSafeOperator{}}}, which only takes 
> the operator but not the arguments into account. To be discussed whether the 
> new API replaces or supplements {{{}SqlOperator#isSafeOperator{}}}.
> 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