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 2015/09/28 22:32:04 UTC
[jira] [Resolved] (CALCITE-895) Simplify "(CASE ... END) =
constant" inside AND or OR
[ https://issues.apache.org/jira/browse/CALCITE-895?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julian Hyde resolved CALCITE-895.
---------------------------------
Resolution: Fixed
Fix Version/s: 1.5.0-incubating
Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/2fa63dda (thanks for the patch, [~seanhychu]!) and improved in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/d697ca16.
> Simplify "(CASE ... END) = constant" inside AND or OR
> -----------------------------------------------------
>
> Key: CALCITE-895
> URL: https://issues.apache.org/jira/browse/CALCITE-895
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Sean Hsuan-Yi Chu
> Assignee: Julian Hyde
> Fix For: 1.5.0-incubating
>
>
> ReduceExpressionsRule.FILTER_INSTANCE does not simplify a Filter, which has “Case-When IsNull” under OR or AND.
> For example, a query like this:
> {code}
> select *
> from emp
> where case when sal = 1000 then null else 1 end is null OR sal = 2000
> {code}
> The condition in the filter can be rewritten as "sal = 1000 OR sal = 2000". However, for now, Calcite does not do the simplification. Instead, Calcite output this plan:
> {code}
> LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
> LogicalFilter(condition=[OR(IS NULL(CASE(=($5, 1000), null, 1)), =($5, 2000))])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)