[jira] [Commented] (CALCITE-1413) New CASE statement simplification

2018-10-17 Thread Jesus Camacho Rodriguez (JIRA)


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

Jesus Camacho Rodriguez commented on CALCITE-1413:
--

Fixed in 
[b470a0c|http://git-wip-us.apache.org/repos/asf/calcite/commit/b470a0c].

> 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)


[jira] [Commented] (CALCITE-1413) New CASE statement simplification

2018-10-12 Thread Julian Hyde (JIRA)


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

Julian Hyde commented on CALCITE-1413:
--

I'll let [~jcamachorodriguez] review this. Two minor things:
* Be sure to use 2/4 indentation. You use 4/8 in some places.
* The fields in CaseBranch should be final. Or you can make it extend 
Pair.

> 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)


[jira] [Commented] (CALCITE-1413) New CASE statement simplification

2018-10-11 Thread Zoltan Haindrich (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-1413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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)


[jira] [Commented] (CALCITE-1413) New CASE statement simplification

2016-12-22 Thread Julian Hyde (JIRA)

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

Julian Hyde commented on CALCITE-1413:
--

I'd remove the "if p1...pn cannot be nullable" restriction and wrap each with 
"... is true" or "... is false" as appropriate. If "p" is not null, then "p is 
true" will quickly simplify to "p" and "p is false" will simplify to "not p".

> 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)


[jira] [Commented] (CALCITE-1413) New CASE statement simplification

2016-10-05 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-1413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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)