[jira] [Commented] (CALCITE-2620) Simplify "coalesce(null,x)" to "x"

2018-10-15 Thread Julian Hyde (JIRA)


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

Julian Hyde commented on CALCITE-2620:
--

You’d be surprised how often “no brainer” optimizations come up in generated 
code, or following view expansions. But there’s a great example of COALESCE 
within Calcite itself.

If you write “select * from emp full join dept using (deptno)” then there will 
be only one “deptno” column in the output. Calcite will populate it using 
“coalesce(emp.deptno, dept.deptno)”. If “emp” is a view and its “deptno” column 
is defined to be “null” then we will end up with “coalesce(null, dept.deptno)”.

> Simplify "coalesce(null,x)" to "x"
> --
>
> Key: CALCITE-2620
> URL: https://issues.apache.org/jira/browse/CALCITE-2620
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Affects Versions: 1.18.0
>Reporter: pengzhiwei
>Assignee: Julian Hyde
>Priority: Major
>
> "coalesce(x0,x1,.)" can be simplified if any of "xi" is null literal.
> e.g.  "coalesce(null,x)" can simplify to "x", "coalesce(x,null,y)" can 
> simplify to "coalesce(x,y)"



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2620) Simplify "coalesce(null,x)" to "x"

2018-10-14 Thread zhen wang (JIRA)


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

zhen wang commented on CALCITE-2620:


[~pzw2018] while this optimization surely looks reasonable, can I ask under 
what circumstances would people/software write such an expression ?

> Simplify "coalesce(null,x)" to "x"
> --
>
> Key: CALCITE-2620
> URL: https://issues.apache.org/jira/browse/CALCITE-2620
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Affects Versions: 1.18.0
>Reporter: pengzhiwei
>Assignee: Julian Hyde
>Priority: Major
>
> "coalesce(x0,x1,.)" can be simplified if any of "xi" is null literal.
> e.g.  "coalesce(null,x)" can simplify to "x", "coalesce(x,null,y)" can 
> simplify to "coalesce(x,y)"



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2620) Simplify "coalesce(null,x)" to "x"

2018-10-12 Thread pengzhiwei (JIRA)


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

pengzhiwei commented on CALCITE-2620:
-

[~julianhyde],In  -CALCITE-2506- this issue has not fixed. I fix it in the 
[PR882|[http://example.com|https://github.com/apache/calcite/pull/882]]

> Simplify "coalesce(null,x)" to "x"
> --
>
> Key: CALCITE-2620
> URL: https://issues.apache.org/jira/browse/CALCITE-2620
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Affects Versions: 1.18.0
>Reporter: pengzhiwei
>Assignee: Julian Hyde
>Priority: Major
>
> "coalesce(x0,x1,.)" can be simplified if any of "xi" is null literal.
> e.g.  "coalesce(null,x)" can simplify to "x", "coalesce(x,null,y)" can 
> simplify to "coalesce(x,y)"



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2620) Simplify "coalesce(null,x)" to "x"

2018-10-12 Thread Julian Hyde (JIRA)


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

Julian Hyde commented on CALCITE-2620:
--

In the fix to CALCITE-2506 I see {code}checkSimplify2(coalesce(gt(nullInt, 
nullInt), trueLiteral),
"COALESCE(null, true)", "COALESCE(null, true)");{code}

The fact that "COALESCE(null, true)" remains in the simplified result, rather 
than having been further simplified to "true", implies that this bug is not 
fixed.

> Simplify "coalesce(null,x)" to "x"
> --
>
> Key: CALCITE-2620
> URL: https://issues.apache.org/jira/browse/CALCITE-2620
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Affects Versions: 1.18.0
>Reporter: pengzhiwei
>Assignee: Julian Hyde
>Priority: Major
>
> "coalesce(x0,x1,.)" can be simplified if any of "xi" is null literal.
> e.g.  "coalesce(null,x)" can simplify to "x", "coalesce(x,null,y)" can 
> simplify to "coalesce(x,y)"



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2620) Simplify "coalesce(null,x)" to "x"

2018-10-11 Thread Haisheng Yuan (JIRA)


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

Haisheng Yuan commented on CALCITE-2620:


This can be fixed using patch in 
https://github.com/apache/calcite/pull/836/files, which I closed.

> Simplify "coalesce(null,x)" to "x"
> --
>
> Key: CALCITE-2620
> URL: https://issues.apache.org/jira/browse/CALCITE-2620
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Affects Versions: 1.18.0
>Reporter: pengzhiwei
>Assignee: Julian Hyde
>Priority: Major
>
> "coalesce(x0,x1,.)" can be simplified if any of "xi" is null literal.
> e.g.  "coalesce(null,x)" can simplify to "x", "coalesce(x,null,y)" can 
> simplify to "coalesce(x,y)"



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)