[ https://issues.apache.org/jira/browse/IGNITE-22762?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Aleksey Plekhanov resolved IGNITE-22762. ---------------------------------------- Fix Version/s: 2.18 Resolution: Fixed Fixed by IGNITE-24378 > Calcite engine. Validated COALESCE return type not equals to relational > algebra return type > ------------------------------------------------------------------------------------------- > > Key: IGNITE-22762 > URL: https://issues.apache.org/jira/browse/IGNITE-22762 > Project: Ignite > Issue Type: Bug > Reporter: Aleksey Plekhanov > Assignee: Aleksey Plekhanov > Priority: Major > Labels: calcite, ise > Fix For: 2.18 > > > Reproducer: > {noformat} > sql("select coalesce(?, 1)", 0); > {noformat} > Fails with an exception: > {noformat} > java.lang.AssertionError: Conversion to relational algebra failed to preserve > datatypes: > validated type: > RecordType(INTEGER NOT NULL EXPR$0) NOT NULL > converted type: > RecordType(INTEGER EXPR$0) NOT NULL > rel: > LogicalProject(EXPR$0=[CASE(IS NOT NULL(?0), ?0, 1)]) > LogicalValues(tuples=[[{ 0 }]]) > at > org.apache.calcite.sql2rel.SqlToRelConverter.checkConvertedType(SqlToRelConverter.java:497) > ~[calcite-core-1.34.0.jar:1.34.0] > at > org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:612) > ~[calcite-core-1.34.0.jar:1.34.0] > at > org.apache.ignite.internal.processors.query.calcite.prepare.IgnitePlanner.rel(IgnitePlanner.java:340) > ~[classes/:?] > at > org.apache.ignite.internal.processors.query.calcite.prepare.PlannerHelper.optimize(PlannerHelper.java:76) > ~[classes/:?] > {noformat} > Root cause: COALESCE converted to CASE operator via > {{SqlCoalesceFunction#rewriteCall}} method. After convertion each operand is > cloned (IF IS NOT NULL (op) THEN op), and type is derived for each clone of > operand individually. These types can be different, and CASE operator can't > determine that operands are equal, since it has another type (see > SqlCaseOperator#inferTypeFromValidator and > SqlCaseOperator#inferTypeFromOperands methods) -- This message was sent by Atlassian Jira (v8.20.10#820010)