You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Zoltan Haindrich (JIRA)" <ji...@apache.org> on 2018/10/11 15:13:01 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=16646586#comment-16646586 ]
Zoltan Haindrich commented on CALCITE-1413:
-------------------------------------------
opened [PR#886|https://github.com/apache/calcite/pull/886];
it actually contains ~4 somewhat distinct changes:
* a small refactor to make it more readable when the case branches are simplified/processed/etc - the fact that else's value didn't have condition made the processing kinda hard to read.
* simplification of case branches - this also makes a bug go away in case of {{RexUnknownAs.TRUE}} is used - I guess we right now don't actually use that...
* before boolean simplification
** case conditional are wrapped into {{IS TRUE}} blocks if needed
** return values are casted to the return type if needed
* addition of the new case conversion logic described in the jira description
[~julianhyde], [~jcamachorodriguez]: please let me know if you think this is too much at once - and I should be breaking this up into smaller parts
> 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: Zoltan Haindrich
> Priority: Major
>
> 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
(v7.6.3#76005)