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

Identical conditions in the WHERE clause cause assertion error

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3.0-incubating
    • Component/s: None
    • Labels:
      None

      Description

      The following is a simple example,
      select empno
      from EMP
      where deptno in (1, 2) or deptno in (1, 2)
      (Using AND can also reproduce this issue)

      We have two identical conditions in the where-clause. Queries falling in this pattern triggers assertion error (SqlToRelConverter.java:4083)

        Activity

        Hide
        seanhychu Sean Hsuan-Yi Chu added a comment -

        I have some idea regarding this. I am trying to fix it.

        Show
        seanhychu Sean Hsuan-Yi Chu added a comment - I have some idea regarding this. I am trying to fix it.
        Hide
        seanhychu Sean Hsuan-Yi Chu added a comment -

        The issue comes from the fact that
        In SqlToRelConverter.java, when we register subquery into subqueryList, we use equalDeep to avoid registering the (logically) same instance twice. However, when we lookup instances, we do not repeat the same logic.
        There are two ways to tackle this issue.

        1. Globally, less preferable:
        Implement SqlNode's equals & hashCode methods to let subqueryMap perform correctly. This does not sound preferable because it is way too global.

        2. Locally, our patches working towards that direction:
        When look up subqueries, perform the same logic as the way when ones were registered. See thew pull request:
        https://github.com/apache/incubator-calcite/pull/82

        Show
        seanhychu Sean Hsuan-Yi Chu added a comment - The issue comes from the fact that In SqlToRelConverter.java, when we register subquery into subqueryList, we use equalDeep to avoid registering the (logically) same instance twice. However, when we lookup instances, we do not repeat the same logic. There are two ways to tackle this issue. 1. Globally, less preferable: Implement SqlNode's equals & hashCode methods to let subqueryMap perform correctly. This does not sound preferable because it is way too global. 2. Locally, our patches working towards that direction: When look up subqueries, perform the same logic as the way when ones were registered. See thew pull request: https://github.com/apache/incubator-calcite/pull/82
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/af01c5af .
        Hide
        julianhyde Julian Hyde added a comment -

        Resolved in release 1.3.0-incubating (2015-05-30).

        Show
        julianhyde Julian Hyde added a comment - Resolved in release 1.3.0-incubating (2015-05-30).

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            seanhychu Sean Hsuan-Yi Chu
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development