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

Off-by-one translation of ON clause of JOIN

    Details

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

      Description

      If joining an expression on the LHS of a join to the first column of the RHS of the join, the join condition is not correctly translated. For instance,

      ```sql
      SELECT * FROM emp JOIN dept on emp.deptno + 0 = dept.deptno
      ```

      becomes

      ```
      JoinRel(condition=[=($9, $9)], joinType=[inner])
      ```

      but should be

      ```
      JoinRel(condition=[=($9, $10)], joinType=[inner])
      ```

      This can occur even if you are apparently just equi-joining columns. If the columns have different types (which might happen if they are from different sources) then even `emp.deptno = dept.deptno` might have an implicit cast.

      Problem is in `SqlToRelConverter.pushDownJoinConditions`. A new expression is added to the LHS, and it has the same ID as the expression referencing the RHS.

      ---------------- Imported from GitHub ----------------
      Url: https://github.com/julianhyde/optiq/issues/245
      Created by: julianhyde
      Labels: bug,
      Assignee: julianhyde
      Created at: Fri Apr 11 00:21:54 CEST 2014
      State: closed

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            github-import GitHub Import
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development