NobiGo commented on a change in pull request #2458:
URL: https://github.com/apache/calcite/pull/2458#discussion_r690868395
##########
File path:
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
##########
@@ -329,7 +330,17 @@ public Result visit(Filter e) {
ImmutableSet.of(Clause.HAVING));
parseCorrelTable(e, x);
final Builder builder = x.builder(e);
- builder.setHaving(builder.context.toSql(null, e.getCondition()));
+ SqlNode condition = builder.context.toSql(null, e.getCondition());
+ SqlNode existHaving = x.asSelect().getHaving();
+ if (existHaving != null) {
+ // if input Aggregate RelNode contains existHaving, need
+ // to create AND expression with connect condition and existHaving
+ // then update input Aggregate's Having condition.
+ condition = SqlUtil.andExpressions(condition, existHaving);
+ x.asSelect().setHaving(condition);
+ } else {
+ builder.setHaving(condition);
+ }
Review comment:
done.
##########
File path:
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
##########
@@ -504,9 +542,18 @@ protected Builder buildAggregate(Aggregate e, Builder
builder,
SqlStdOperatorTable.ROLLUP.createCall(SqlParserPos.ZERO, groupKeys));
default:
case OTHER:
+ // Make sure that the group sets contains all bits.
+ final List<ImmutableBitSet> groupSets;
+ if (aggregate.getGroupSet()
+ .equals(ImmutableBitSet.union(aggregate.groupSets))) {
+ groupSets = aggregate.getGroupSets();
+ } else {
+ groupSets = new ArrayList<>(aggregate.getGroupSets());
+ groupSets.add(0, aggregate.getGroupSet());
Review comment:
Done. Thank you for your advice.
--
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]