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

Aleksey Plekhanov updated IGNITE-25830:
---------------------------------------
    Labels: calcite ise  (was: ise)

> Calcite engine. Double coalesce with null literal throws an exception
> ---------------------------------------------------------------------
>
>                 Key: IGNITE-25830
>                 URL: https://issues.apache.org/jira/browse/IGNITE-25830
>             Project: Ignite
>          Issue Type: Bug
>            Reporter: Aleksey Plekhanov
>            Priority: Major
>              Labels: calcite, ise
>
> Quries like:
> {code:sql}
> SELECT COALESCE(COALESCE(null, 'a'), 'b')
> {code}
> Fail with:
> {noformat}
> java.lang.AssertionError: Conversion to relational algebra failed to preserve 
> datatypes:
> validated type:
> RecordType(VARCHAR(1024) CHARACTER SET "UTF-8" NOT NULL EXPR$0) NOT NULL
> converted type:
> RecordType(CHAR(1) CHARACTER SET "UTF-8" NOT NULL EXPR$0) NOT NULL
> {noformat}
> Query works on pure Calcite. 
> Query like 
> {code:sql}
> SELECT COALESCE(COALESCE(null::varchar, 'a'), 'b')
> {code}
> Also works.
> Operator {{COALESCE}} is converted to {{CASE WHEN ... IS NOT NULL}}. Operator 
> {{IS_NOT_NULL}} has {{InferTypes.VARCHAR_1024}} operand type inference. The 
> type of the whole upper {{CASE WHEN}} is inferred as {{VARCHAR(1024)}}, but 
> when converted to Rex is inferred as {{CHAR(1)}}. For some reason pure 
> Calcite infer {{CASE WHEN}} type correctly. Need to investigate our changes 
> in {{IgniteSqlValidator.inferUnknownTypes}}.
> {{test_coalesce.test_ignored}} need to be deleted after this fix



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to