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 2016/10/05 16:12:20 UTC
[jira] [Commented] (CALCITE-1413) New CASE statement simplification
[ https://issues.apache.org/jira/browse/CALCITE-1413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15549180#comment-15549180 ]
Julian Hyde commented on CALCITE-1413:
--------------------------------------
Makes sense. This generalizes work done in CALCITE-1220, where e1 and e2 had to be constants (TRUE or FALSE).
It's worth pulling in CALCITE-1054, which uses RexNode rewrites to convert 3-valued booleans to 2-valued booleans.
> New CASE statement simplification
> ---------------------------------
>
> Key: CALCITE-1413
> URL: https://issues.apache.org/jira/browse/CALCITE-1413
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.9.0
> Reporter: Jesus Camacho Rodriguez
> Assignee: Jesus Camacho Rodriguez
> Fix For: 1.11.0
>
>
> Another possible simplification for CASE statements that return boolean values.
> {code:sql}
> CASE
> WHEN p1 THEN e1
> WHEN p2 THEN e2
> ELSE TRUE
> END
> {code}
> where e1...en are boolean expressions, can be rewritten into:
> {code:sql}
> (p1 and e1) or (p2 and e2 and not(p1)) or (not(p1) and not(p2))
> {code}
> if p1...pn cannot be nullable.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)