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

Sql. Incorrect type conversion for dynamic parameters - CAST operation ignores type precision.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0
    • sql

    Description

      Current implementation of expression execution runtime incorrectly translates types of dynamic parameters because (a) it losses type informations of dynamic parameters (see https://issues.apache.org/jira/browse/IGNITE-18831), (b) it goes against the rules of calcite's enumerables/link4j (on which the code is based), which expect dynamic parameters to be converted into their java values according to their inferred types.

      The following code illustrates the problem with character types:

       @Test
          public void test() {
              assertQuery("SELECT CAST(? AS VARCHAR(2))").withParams("abcd").returns("ab").check();
          }
      

      The code returns `abcd` when `ab` is expected.

      Problem with numeric types:

       @Test
          public void test() {
              assertQuery("SELECT CAST(? AS DECIMAL(2))").withParams(new BigDecimal("123")).check();
          }
      

      The code returns original value where Postgres/Oracle/SQL Server return conversion error.

      Solution: convert values of dynamic parameters to java values according to type information inferred at the validation stage and pass converted values to expression execution runtime.

      Attachments

        Issue Links

          Activity

            People

              mzhuravkov Maksim Zhuravkov
              mzhuravkov Maksim Zhuravkov
              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 - 3h 40m
                  3h 40m