[ 
https://issues.apache.org/jira/browse/CALCITE-2288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stamatis Zampetakis closed CALCITE-2288.
----------------------------------------
       Resolution: Not A Problem
    Fix Version/s: 1.19.0

The problem seems to be solved, so I am closing this issue.

> Type assertion error when reducing partially constant expression
> ----------------------------------------------------------------
>
>                 Key: CALCITE-2288
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2288
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>            Reporter: Laurent Goujon
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.19.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Probably a follow up of CALCITE-2041
> The following query failed at planning time with an assertion error:
> {code:sql}
> SELECT
>   EXTRACT(SECOND FROM CAST(CASE WHEN TRUE THEN {ts '2018-01-01 01:23:45'} 
> ELSE NULL END AS TIMESTAMP)) =
>   EXTRACT(SECOND FROM d)
> FROM (VALUES({ts '2018-01-01 01:23:45'})) tbl(d
> {code}
> Stacktrace is:
> {noformat}
> java.lang.AssertionError: Cannot add expression of different type to set:
> set type is RecordType(BOOLEAN EXPR$0) NOT NULL
> expression type is RecordType(BOOLEAN NOT NULL EXPR$0) NOT NULL
> set is 
> rel#4:LogicalProject(input=HepRelVertex#3,EXPR$0==(EXTRACT(FLAG(SECOND), 
> CAST(CASE(true, 2018-01-01 01:23:45, null)):TIMESTAMP(0)), 
> EXTRACT(FLAG(SECOND), $0)))
> expression is LogicalProject#6
>       at 
> org.apache.calcite.plan.RelOptUtil.verifyTypeEquivalence(RelOptUtil.java:413)
>       at 
> org.apache.calcite.plan.hep.HepRuleCall.transformTo(HepRuleCall.java:57)
>       at 
> org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:234)
>       at 
> org.apache.calcite.rel.rules.ReduceExpressionsRule$ProjectReduceExpressionsRule.onMatch(ReduceExpressionsRule.java:290)
>       at 
> org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:317)
>       at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:556)
>       at 
> org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:415)
>       at 
> org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:252)
>       at 
> org.apache.calcite.plan.hep.HepInstruction$RuleInstance.execute(HepInstruction.java:127)
>       at 
> org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:211)
>       at 
> org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:198)
> ...
> {noformat}
> As far as I can tell, the issue is in 
> {{ReduceExpressionRules#reduceExpressions}}: when the expression is partially 
> reduced, the reduced expression lost its type nullability, which is not added 
> back by the simplifier.



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

Reply via email to