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

JDBC adapter generates SQL with invalid field names if Filter's row type is different from its input

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.21.0
    • 1.22.0
    • jdbc-adapter
    • None

    Description

      JDBC adapter generates SQL with invalid field names if a Filter object's row type is different from its input. Usually a Filter object's row type is identical to its input's row type (because that is how it derives its row type on construction), but if you call RelNode.replaceInput after construction it is possible to make the field names inconsistent.

      Here is an example of the wrong SQL generated:

      SELECT D AS `emps.deptno`
      FROM (
        SELECT DEPTNO AS D2, COUNT(*) AS `emps.count`
        FROM `scott`.EMP
        GROUP BY DEPTNO
        HAVING COUNT(*) < 2) AS `t1`
      

      Note that the sub-query returns a column D2 but the outer SELECT expression refers to D, because that was the name in the row type of the Filter (which became the HAVING clause in the generated SQL).

      Attachments

        Activity

          People

            julianhyde Julian Hyde
            julianhyde Julian Hyde
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: