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

Equality of nested ROWs returns false for identical literal value

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.21.0
    • Fix Version/s: 1.22.0
    • Component/s: None

      Description

      Similar to CALCITE-3021.
      Problem can be reproduced via:

      select * from
      (values
          (1, ROW(1,1)),
          (2, ROW(2,2)),
          (3, ROW(1,1)),
          (4, ROW(2,2))) as t(id,struct)
      where t.struct = ROW(2,2);
      

      which returns no results, instead of the expected (I have run the same query in PostgreSQL, and it returns this result):

      +----+--------+
      | ID | STRUCT |
      +----+--------+
      |  2 | {2, 2} |
      |  4 | {2, 2} |
      +----+--------+
      

      The issue is that the comparison is done via SqlFunctions#eq(Object b0, Object b1)

      public static boolean eq(Object b0, Object b1) {
        return b0.equals(b1);
      }
      

      And in this case we have two different Object[], with the same content, so they should be identified as equals (but they are not, based on Object#equals). Probably the simplest solution would be overloading the eq method for Object[] parameters:

      public static boolean eq(Object[] b0, Object[] b1) {
        return Arrays.deepEquals(b0, b1);
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rubenql Ruben Q L
                Reporter:
                rubenql Ruben Q L
              • Votes:
                0 Vote for this issue
                Watchers:
                1 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
                  1h