You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "libenchao (via GitHub)" <gi...@apache.org> on 2023/05/03 09:23:32 UTC
[GitHub] [calcite] libenchao commented on a diff in pull request #3052: [CALCITE-5506] RelToSqlConverter should retain the aggregation logic
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org