Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-23726

Calcite engine. Functions NVL and DECODE fail when used with parameters of different data types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.0.0-beta1
    • None
    • sql

    Description

      For example, query:

      select nvl('1', 2)
      

      Fails with:

      Cannot infer return type for NVL; operand types: [CHAR(1), INTEGER] 

      Query:

      select decode('1', 1, '1', '2')
      

      Fails with:

      while resolving method 'eq[class java.lang.String, int]' in class class org.apache.calcite.runtime.SqlFunctions 

      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:

      select case when '1' is not null then '1' else 2 end
      select case when '1' = 1 then '1' else '2' end
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              zstan Evgeny Stanilovsky
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: