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

Vladimir Sitnikov commented on CALCITE-3746:
--------------------------------------------

[~Chunwei Lei], why don't you add the metadata to your user-defined-functions 
instead?
If you add the metadata, then Calcite would never call the function with null 
arguments, and it would enable Calcite to optimize the queries better.

For example, can you declare the function as a strict one? That would tell 
Calcite the function always returns null if any of the arguments is null.

Note: RexSimplify code is huge. It deals with lots of things, and I don't see a 
way of adding an option that would treat `is not null` in every possible case.
Then I don't even get what you mean by "retain order" because predicates might 
float all over the place. There is no order. RexSimplify might infer the 
predicates, etc, etc.

I believe https://dba.stackexchange.com/a/115759 is relevant.

> RexSimplify changes the order of IS NOT NULL in And RexNode
> -----------------------------------------------------------
>
>                 Key: CALCITE-3746
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3746
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.20.0
>            Reporter: pengzhiwei
>            Assignee: Chunwei Lei
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The RexSimplify changes the order of IS NOT NULL in And RexNode.The following 
> expression 
> {code:java}
> a is not null and length(a) > 0{code}
> is optimazted to 
> {code:java}
> length(a) > 0 and a is not null{code}
> which will affect the logic short circuit for null-test.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to