You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2017/11/25 19:21:00 UTC

[jira] [Resolved] (CALCITE-2041) When ReduceExpressionRule simplifies a nullable expression, allow the result to change type to NOT NULL

     [ https://issues.apache.org/jira/browse/CALCITE-2041?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Hyde resolved CALCITE-2041.
----------------------------------
    Resolution: Fixed

Fixed in [0ea976ee|http://git-wip-us.apache.org/repos/asf/calcite/commit/0ea976ee]. Thanks, [~bslim] and [~jcamachorodriguez].

I also parameterized the existing ReduceExpressionRule sub-classes so that we can test them in the new {{matchNullability}} mode.

> When ReduceExpressionRule simplifies a nullable expression, allow the result to change type to NOT NULL
> -------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2041
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2041
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: slim bouguerra
>            Assignee: Julian Hyde
>             Fix For: 1.15.0
>
>
> In some cases, the user needs to select whether or not to add casts that match nullability.
> One of the motivations behind this is to avoid unnecessary casts like the following example.
> original filter 
> {code}
> OR(AND(>=($0, CAST(_UTF-16LE'2010-01-01 00:00:00 UTC'):TIMESTAMP_WITH_LOCAL_TIME_ZONE(15)), <=($0, CAST(_UTF-16LE'2012-03-01 00:00:00 UTC'):TIMESTAMP_WITH_LOCAL_TIME_ZONE(15))))
> {code}
> the optimized expression with matching nullability
> {code}
> OR(AND(CAST(>=($0, 2010-01-01 00:00:00)):BOOLEAN, CAST(<=($0, 2012-03-01 00:00:00)):BOOLEAN))
> {code}
> As you can see this extra cast gets into the way of following plan optimization steps.
> The desired expression can be obtained by turning off the nullability matching.
> {code}
> OR(AND(>=($0, 2010-01-01 00:00:00), <=($0, 2012-03-01 00:00:00)))
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)