Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,8 @@ public interface Config extends RelRule.Config {
.addAll(SqlKind.AVG_AGG_FUNCTIONS)
.addAll(SqlKind.COVAR_AVG_AGG_FUNCTIONS)
.add(SqlKind.SUM)
.build();
.build().stream().filter(k -> k != SqlKind.REGR_COUNT)
.collect(ImmutableSet.toImmutableSet());

@Override default AggregateReduceFunctionsRule toRule() {
return new AggregateReduceFunctionsRule(this);
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/org/apache/calcite/rex/RexBuilder.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -39,7 +39,6 @@
import org.apache.calcite.sql.SqlTimeLiteral;
import org.apache.calcite.sql.SqlTimestampLiteral;
import org.apache.calcite.sql.SqlUtil;
import org.apache.calcite.sql.fun.SqlCountAggFunction;
import org.apache.calcite.sql.fun.SqlLibraryOperators;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.sql.parser.SqlParserPos;
Expand Down Expand Up @@ -388,7 +387,7 @@
List<AggregateCall> aggCalls,
Map<AggregateCall, RexNode> aggCallMapping,
IntPredicate isNullable) {
if (aggCall.getAggregation() instanceof SqlCountAggFunction
if (aggCall.getAggregation().getKind() == SqlKind.COUNT
&& !aggCall.isDistinct()) {
final List<Integer> args = aggCall.getArgList();
final List<Integer> nullableArgs = nullableArgs(args, isNullable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ public SqlCountAggFunction(String name) {

public SqlCountAggFunction(String name,
SqlOperandTypeChecker sqlOperandTypeChecker) {
super(name, null, SqlKind.COUNT, ReturnTypes.BIGINT, null,
sqlOperandTypeChecker, SqlFunctionCategory.NUMERIC, false, false,
Optionality.FORBIDDEN);
this(name, sqlOperandTypeChecker, SqlKind.COUNT);
}

public SqlCountAggFunction(String name,
SqlOperandTypeChecker sqlOperandTypeChecker,
SqlKind sqlKind) {
super(name, null, sqlKind, ReturnTypes.BIGINT, null, sqlOperandTypeChecker,
SqlFunctionCategory.NUMERIC, false, false, Optionality.FORBIDDEN);
}

//~ Methods ----------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
public class SqlRegrCountAggFunction extends SqlCountAggFunction {
public SqlRegrCountAggFunction(SqlKind kind) {
super("REGR_COUNT", OperandTypes.NUMERIC_NUMERIC);
super("REGR_COUNT", OperandTypes.NUMERIC_NUMERIC, kind);
checkArgument(SqlKind.REGR_COUNT == kind, "unsupported sql kind: " + kind);
}
}
Loading