Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.21.0
-
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).