[ https://issues.apache.org/jira/browse/CALCITE-3165?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16876315#comment-16876315 ]
Ruben Quesada Lopez edited comment on CALCITE-3165 at 7/1/19 4:15 PM: ---------------------------------------------------------------------- Currently, {{Project#accept(RexShuttle shuttle)}} is implemented as: {code} public RelNode accept(RexShuttle shuttle) { List<RexNode> exps = shuttle.apply(this.exps); if (this.exps == exps) { return this; } return copy(traitSet, getInput(), exps, rowType); } {code} Thus, the original rowType is always kept, even though we know that the list of expressions has been changed, so we might have potentially a different rowType. The idea would be doing something in the line of: {code} public RelNode accept(RexShuttle shuttle) { List<RexNode> exps = shuttle.apply(this.exps); if (this.exps == exps) { return this; } final RelDataType newRowType = RexUtil.createStructType( getInput().getCluster().getTypeFactory(), exps, rowType.getFieldNames(), SqlValidatorUtil.F_SUGGESTER); return copy(traitSet, getInput(), exps, newRowType); } {code} I'll try to provide a unit test to show the problem. was (Author: rubenql): Currently, Project#accept(RexShuttle shuttle) does: {code} public RelNode accept(RexShuttle shuttle) { List<RexNode> exps = shuttle.apply(this.exps); if (this.exps == exps) { return this; } return copy(traitSet, getInput(), exps, rowType); } {code} Thus, the original rowType is always kept, even though we know that the list of expressions has been changed, so we might have potentially a different rowType. The idea would be doing something in the line of: {code} public RelNode accept(RexShuttle shuttle) { List<RexNode> exps = shuttle.apply(this.exps); if (this.exps == exps) { return this; } final RelDataType newRowType = RexUtil.createStructType( getInput().getCluster().getTypeFactory(), exps, rowType.getFieldNames(), SqlValidatorUtil.F_SUGGESTER); return copy(traitSet, getInput(), exps, newRowType); } {code} I'll try to provide a unit test to show the problem. > Project#accept(RexShuttle shuttle) does not update rowType > ---------------------------------------------------------- > > Key: CALCITE-3165 > URL: https://issues.apache.org/jira/browse/CALCITE-3165 > Project: Calcite > Issue Type: Bug > Components: core > Reporter: Ruben Quesada Lopez > Assignee: Ruben Quesada Lopez > Priority: Minor > > {{Project#accept(RexShuttle shuttle)}} can return a copy of the original > Project, if the list of expressions is modified by the shuttle. However, this > Project copy will maintain the original rowType, which might be wrong because > this type is based on the expressions list (which was modified by the shuttle) -- This message was sent by Atlassian JIRA (v7.6.3#76005)