You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Paul Rogers (JIRA)" <ji...@apache.org> on 2018/11/06 21:37:00 UTC
[jira] [Updated] (IMPALA-7750) Prune trivial ELSE clause in CASE
simplification
[ https://issues.apache.org/jira/browse/IMPALA-7750?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul Rogers updated IMPALA-7750:
--------------------------------
Description:
A trivial optimization is to omit ELSE if it adds no value:
{code:sql}
CASE WHEN id = 10 THEN id ELSE NULL END
{code}
The {{ELSE}} case defaults to null if not provided, so the above can be rewritten to:
{code:sql}
CASE WHEN id = 10 THEN id END
{code}
Also, the simplification can omit the trailing {{WHEN}} clause if it returns {{NULL}}. For example:
{code:sql}
CASE WHEN id = 0 THEN 10 WHEN id = 1 THEN NULL END
{code}
Should be simplified to:
{code:sql}
CASE WHEN id = 0 THEN 10 END
{code}
was:
A trivial optimization is to omit ELSE if it adds no value:
{code:sql}
CASE WHEN id = 10 THEN id ELSE NULL END
{code}
The {{ELSE}} case defaults to null if not provided, so the above can be rewritten to:
{code:sql}
CASE WHEN id = 10 THEN id END
{code}
Also, the simplification can omit the only {{WHEN}} clause if it returns {{NULL}}. For example, when rewriting {{nullif()}} we get
{code:sql}
CASE WHEN id IS DISTINCT FROM NULL THEN NULL ELSE NULL END
{code}
This should be simplified to just {{NULL}}.
> Prune trivial ELSE clause in CASE simplification
> ------------------------------------------------
>
> Key: IMPALA-7750
> URL: https://issues.apache.org/jira/browse/IMPALA-7750
> Project: IMPALA
> Issue Type: Improvement
> Components: Frontend
> Affects Versions: Impala 3.0
> Reporter: Paul Rogers
> Priority: Trivial
>
> A trivial optimization is to omit ELSE if it adds no value:
> {code:sql}
> CASE WHEN id = 10 THEN id ELSE NULL END
> {code}
> The {{ELSE}} case defaults to null if not provided, so the above can be rewritten to:
> {code:sql}
> CASE WHEN id = 10 THEN id END
> {code}
> Also, the simplification can omit the trailing {{WHEN}} clause if it returns {{NULL}}. For example:
> {code:sql}
> CASE WHEN id = 0 THEN 10 WHEN id = 1 THEN NULL END
> {code}
> Should be simplified to:
> {code:sql}
> CASE WHEN id = 0 THEN 10 END
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org