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

Aleksey Plekhanov updated IGNITE-23673:
---------------------------------------
    Description: 
For example, query:
{code:java}
select nvl('1', 2)
{code}
Fails with:
{noformat}
Cannot infer return type for NVL; operand types: [VARCHAR, INTEGER]
{noformat}

Query:
{code:java}
select decode('1', 1, '1', '2')
{code}
Fails with:
{noformat}
org.apache.ignite.IgniteCheckedException: while resolving method 'eq[class 
java.lang.String, int]' in class class org.apache.calcite.runtime.SqlFunctions
{noformat}

These functions are rewritten to the {{CASE-WHEN}} operator after the 
validation, but fail on validation. But if we use {{CASE-WHEN}} in the original 
query, it works well, types are casted correctly and validation passed:
{code:java}
select case when '1' is not null then '1' else 2 end
select case when '1' = 1 then '1' else '2' end
{code}
 


  was:
For example:

{code:java}
select nvl('1', 2)
{code}
Fails with:
{noformat}
Cannot infer return type for NVL; operand types: [VARCHAR, INTEGER]
{noformat}

{code:java}
select decode('1', 1, '1', '2')
{code}
Fails with:
{noformat}
org.apache.ignite.IgniteCheckedException: while resolving method 'eq[class 
java.lang.String, int]' in class class org.apache.calcite.runtime.SqlFunctions
{noformat}

These functions are rewritten to the {{CASE-WHEN}} operator after the 
validation, but fail on validation. But if we use {{CASE-WHEN}} in the original 
query, it works well, types are casted correctly and validation passed:
{code:java}
select case when '1' is not null then '1' else 2 end
select case when '1' = 1 then '1' else '2' end
{code}
 



> Calcite engine. Functions NVL and DECODE fail when used with parameters of 
> different data types 
> ------------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-23673
>                 URL: https://issues.apache.org/jira/browse/IGNITE-23673
>             Project: Ignite
>          Issue Type: Bug
>            Reporter: Aleksey Plekhanov
>            Assignee: Aleksey Plekhanov
>            Priority: Major
>              Labels: calcite, ise
>
> For example, query:
> {code:java}
> select nvl('1', 2)
> {code}
> Fails with:
> {noformat}
> Cannot infer return type for NVL; operand types: [VARCHAR, INTEGER]
> {noformat}
> Query:
> {code:java}
> select decode('1', 1, '1', '2')
> {code}
> Fails with:
> {noformat}
> org.apache.ignite.IgniteCheckedException: while resolving method 'eq[class 
> java.lang.String, int]' in class class org.apache.calcite.runtime.SqlFunctions
> {noformat}
> These functions are rewritten to the {{CASE-WHEN}} operator after the 
> validation, but fail on validation. But if we use {{CASE-WHEN}} in the 
> original query, it works well, types are casted correctly and validation 
> passed:
> {code:java}
> select case when '1' is not null then '1' else 2 end
> select case when '1' = 1 then '1' else '2' end
> {code}
>  



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

Reply via email to