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

Calcite. Wrong numeric type coercion with set-op operations.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.14
    • 2.17
    • None
    • SQL Calcite: Fixed incorrect result in unions in case of different types of numeric results.
    • Release Notes Required

    Description

      Wrong numers cast with operators like UNION / INTERSECT / EXCEPT.

      Reproducer:

          public void testUnionWithNumerics() {
              sql("CREATE TABLE t0(id INT PRIMARY KEY, val INT)");
              sql("CREATE TABLE t1(id INT PRIMARY KEY, val DECIMAL)");
              sql("INSERT INTO t0 VALUES (1, 10)");
              sql("INSERT INTO t1 VALUES (1, 10)");
      
              assertQuery(ignite(0), "SELECT val from t0 UNION select val from t1")
                  .returns(new BigDecimal(10))
                  .ordered()
                  .check();
          }
      

      Error:

      java.lang.AssertionError: Collections sizes are not equal:
      Expected: [[10]]
      Actual:   [[10], [10]] 
      

      Or:

          public void testIntersectWithNumerics() {
              sql("CREATE TABLE t0(id INT PRIMARY KEY, val INT)");
              sql("CREATE TABLE t1(id INT PRIMARY KEY, val DECIMAL)");
              sql("INSERT INTO t0 VALUES (1, 10), (2, 20), (3, 30), (4, 40), (5, 50)");
              sql("INSERT INTO t1 VALUES (1, 10), (2, 20), (3, 300), (4, 400), (5, 50)");
      
              assertQuery(ignite(0), "SELECT val from t0 INTERSECT select val from t1")
                  .returns(new BigDecimal(10))
                  .returns(new BigDecimal(20))
                  .returns(new BigDecimal(50))
                  .ordered()
                  .check();
          }
      

      Error:

      java.lang.AssertionError: Collections sizes are not equal:
      Expected: [[10], [20], [50]]
      Actual:   [] 
      

      Adoption of #IGNITE-21827 and #IGNITE-20649

      Attachments

        Issue Links

          Activity

            People

              vladsz83 Vladimir Steshin
              vladsz83 Vladimir Steshin
              Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 10m
                  10m