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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.17
    • None
    • SQL Calcite: Fixed NVL/DECODE failure when used with parameters of different data types
    • Release Notes Required

    Description

      For example, query:

      select nvl('1', 2)
      

      Fails with:

      Cannot infer return type for NVL; operand types: [VARCHAR, INTEGER]
      

      Query:

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

      Fails with:

      org.apache.ignite.IgniteCheckedException: 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

              alex_pl Aleksey Plekhanov
              alex_pl Aleksey Plekhanov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 50m
                  1h 50m