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

Iurii Gerzhedovich updated IGNITE-23726:
----------------------------------------
    Description: 
For example, query:
{code:java}
select nvl('1', 2)
{code}
Fails with:
{noformat}
Cannot infer return type for NVL; operand types: [CHAR(1), INTEGER] {noformat}
Query:
{code:java}
select decode('1', 1, '1', '2')
{code}
Fails with:
{noformat}
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, 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}
 



> Calcite engine. Functions NVL and DECODE fail when used with parameters of 
> different data types 
> ------------------------------------------------------------------------------------------------
>
>                 Key: IGNITE-23726
>                 URL: https://issues.apache.org/jira/browse/IGNITE-23726
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 3.0.0-beta1
>            Reporter: Evgeny Stanilovsky
>            Priority: Major
>              Labels: ignite-3
>
> For example, query:
> {code:java}
> select nvl('1', 2)
> {code}
> Fails with:
> {noformat}
> Cannot infer return type for NVL; operand types: [CHAR(1), INTEGER] {noformat}
> Query:
> {code:java}
> select decode('1', 1, '1', '2')
> {code}
> Fails with:
> {noformat}
> 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