Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-2591

EnumerableDefaults#mergeJoin should throw error and not return incorrect results when inputs are not ordered

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.17.0
    • 1.18.0
    • core
    • None

    Description

      The merge join implementation should throw a runtime error in case of unsorted inputs.

       

      The assertion  is already present but it is done with Java 'assert' keywork, this makes the assertion not to be evaluated in production.

      It happened in production that due to a bug (out of the scope of this issue) a merge join was fed by an input which was not sorted according to the merge sort keys

      This is current code in 1.17

      int c = leftKey.compareTo(leftKey2);
              if (c != 0) {
                assert c < 0 : "not sorted";
                break;
              }

       

      This change will enable that assertion even when Java assertions are not enabled.

      The impact is not very significant (a few CPU cycles) but prevents invalid results to be returned by the query.

       

      Attachments

        Activity

          People

            julianhyde Julian Hyde
            eolivelli Enrico Olivelli
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: