Niels Pardon created CALCITE-6877: ------------------------------------- Summary: Generate LogicalProject in RelRoot.project() when mapping is not name trivial Key: CALCITE-6877 URL: https://issues.apache.org/jira/browse/CALCITE-6877 Project: Calcite Issue Type: Improvement Components: core Affects Versions: 1.38.0 Reporter: Niels Pardon Assignee: Niels Pardon Fix For: 1.39.0
Currently, the RelRoot.project() method only generates a project relation if the RelRoot fields are: * not ref trivial * or if one of the following is not true: ** is not a DML operation ** is not a force project ** the existing top relation is not already a LogicalProject [https://github.com/apache/calcite/blob/802fce3c41be76fca899ddb8c856d72c754d1520/core/src/main/java/org/apache/calcite/rel/RelRoot.java#L163-L169] The result is that for a simple SQL query that selects a single field from a table and renames the same field we are losing the renaming of the field if we call RelRoot.project() even if we set the force parameter to true since the relational tree embedded in the RelRoot already contains a LogicalProject at the top of the tree. My expectation would be that when I call RelRoot.project() that a LogicalProject is being added also if the RelRoot fields are not name trivial aka they are being renamed. -- This message was sent by Atlassian Jira (v8.20.10#820010)