julianhyde commented on code in PR #4495:
URL: https://github.com/apache/calcite/pull/4495#discussion_r2268399895
##########
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##########
@@ -227,7 +227,8 @@ public static SqlCall stripSeparator(SqlCall call) {
@Override public RelDataType
inferReturnType(SqlOperatorBinding opBinding) {
final RelDataType type = super.inferReturnType(opBinding);
- if (opBinding.getGroupCount() == 0 || opBinding.hasFilter()) {
+ if (opBinding.allowChangeNullable()
Review Comment:
I still don't understand. The javadoc says "Whether to support modifying
nullable when doing type inference in AggCall.". But after reading that
javadoc, I still don't understand why an aggregate would change its nullability.
##########
core/src/main/java/org/apache/calcite/rel/core/AggregateCall.java:
##########
@@ -74,6 +74,7 @@ public class AggregateCall {
public final int filterArg;
public final @Nullable ImmutableBitSet distinctKeys;
public final RelCollation collation;
+ public boolean allowChangeNullable;
Review Comment:
final
##########
core/src/main/java/org/apache/calcite/tools/RelBuilder.java:
##########
@@ -2819,28 +2819,56 @@ private RelBuilder aggregate_(ImmutableBitSet groupSet,
* GROUP_ID returns wrong result</a> and
* <a
href="https://issues.apache.org/jira/browse/CALCITE-4748">[CALCITE-4748]
* If there are duplicate GROUPING SETS, Calcite should return duplicate
- * rows</a>.
+ * rows</a> and
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7126">[CALCITE-7126]
+ * The calculation result of grouping function is wrong</a>.
*/
private RelBuilder rewriteAggregateWithDuplicateGroupSets(
ImmutableBitSet groupSet,
ImmutableSortedMultiset<ImmutableBitSet> groupSets,
List<AggCallPlus> aggregateCalls) {
+ List<AggregateCall> calls =
+ aggregateCalls.stream()
+ .map(AggCallPlus::aggregateCall)
+ .collect(Collectors.toList());
+ return rewriteAggregateWithDuplicateGroupSetsImpl(groupSet, groupSets,
calls);
+ }
+
+ private RelBuilder rewriteAggregateWithDuplicateGroupSetsImpl(
Review Comment:
The other method is private, therefore you can rename it if you like. Adding
`Impl` to the end of an already-long method name doesn't make sense to me.
--
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]