libenchao commented on code in PR #3052:
URL: https://github.com/apache/calcite/pull/3052#discussion_r1183442969
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -1831,6 +1831,21 @@ && hasSortByOrdinal()) {
return true;
}
+ if (rel instanceof Project) {
+ Project project = (Project) rel;
+ RelNode input = project.getInput();
+ // Cannot merge because "select 1 from t"
+ // is different from "select 1 from (select count(1) from t)"
+ final boolean hasInputRef = project.getProjects()
+ .stream()
+ .anyMatch(rex -> RexUtil.containsInputRef(rex));
+ final boolean hasAggregate =
+ input instanceof Aggregate && input.getRowType().getFieldCount() >
0;
Review Comment:
Do you need to add `input.getRowType().getFieldCount() > 0`? (I even doubt
that we will produce `RelNode` which has `0` fields)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]