You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Stamatis Zampetakis (Jira)" <ji...@apache.org> on 2025/10/16 11:14:00 UTC
[jira] [Commented] (CALCITE-7145) RexSimplify should not simplify IS NULL(10/0)
[ https://issues.apache.org/jira/browse/CALCITE-7145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18030330#comment-18030330 ]
Stamatis Zampetakis commented on CALCITE-7145:
----------------------------------------------
I admit that using the term constant for 10 / 0 is slightly abusive. Apart from that since 10 / 0 has different behavior/results from one DBMS to another I feel that it's safer to let {{IS [NOT] NULL (x / 0 )}} as is during simplification so the proposal here and the respective PR makes sense to me. Going further, I don't know of any DBMS that returns {{false}} for {{IS NULL(10/0)}} so the current behavior of simplifier will be considered a bug from most people.
For the historical part, the term "safe" was introduced by CALCITE-1413 to protect against invalid simplifications mostly around conditional (CASE) statements. The division operator is considered unsafe mostly due to the misc semantics of division by zero.
> RexSimplify should not simplify IS NULL(10/0)
> ---------------------------------------------
>
> Key: CALCITE-7145
> URL: https://issues.apache.org/jira/browse/CALCITE-7145
> Project: Calcite
> Issue Type: Bug
> Reporter: Thomas Rebele
> Assignee: Thomas Rebele
> Priority: Major
> Labels: pull-request-available
>
> RexSimplify incorrectly simplifies {{IS NULL(10/0)}} to false and {{IS NOT NULL(10,0)}} to true
> In other DBMS it's either the inverse (sqlite, MySQL, MariaDB), or they throw an exception in both cases (Oracle, Postgres). The behavior was also mentioned in a comment on CALCITE-3368.
> Is it right that throwing an exception during query execution is the expected behavior according to the SQL standard?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)