Java Code Examples for org.apache.calcite.sql.SqlKind#MIN

The following examples show how to use org.apache.calcite.sql.SqlKind#MIN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlinkAggregateRemoveRule.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public boolean matches(RelOptRuleCall call) {
	final Aggregate aggregate = call.rel(0);
	final RelNode input = call.rel(1);
	if (aggregate.getGroupCount() == 0 || aggregate.indicator ||
			aggregate.getGroupType() != Aggregate.Group.SIMPLE) {
		return false;
	}
	for (AggregateCall aggCall : aggregate.getAggCallList()) {
		SqlKind aggCallKind = aggCall.getAggregation().getKind();
		// TODO supports more AggregateCalls
		boolean isAllowAggCall = aggCallKind == SqlKind.SUM ||
				aggCallKind == SqlKind.MIN ||
				aggCallKind == SqlKind.MAX ||
				aggCall.getAggregation() instanceof SqlAuxiliaryGroupAggFunction;
		if (!isAllowAggCall || aggCall.filterArg >= 0 || aggCall.getArgList().size() != 1) {
			return false;
		}
	}

	final RelMetadataQuery mq = call.getMetadataQuery();
	return SqlFunctions.isTrue(mq.areColumnsUnique(input, aggregate.getGroupSet()));
}
 
Example 2
Source File: FlinkAggregateRemoveRule.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public boolean matches(RelOptRuleCall call) {
	final Aggregate aggregate = call.rel(0);
	final RelNode input = call.rel(1);
	if (aggregate.getGroupCount() == 0 || aggregate.indicator ||
			aggregate.getGroupType() != Aggregate.Group.SIMPLE) {
		return false;
	}
	for (AggregateCall aggCall : aggregate.getAggCallList()) {
		SqlKind aggCallKind = aggCall.getAggregation().getKind();
		// TODO supports more AggregateCalls
		boolean isAllowAggCall = aggCallKind == SqlKind.SUM ||
				aggCallKind == SqlKind.MIN ||
				aggCallKind == SqlKind.MAX ||
				aggCall.getAggregation() instanceof SqlAuxiliaryGroupAggFunction;
		if (!isAllowAggCall || aggCall.filterArg >= 0 || aggCall.getArgList().size() != 1) {
			return false;
		}
	}

	final RelMetadataQuery mq = call.getMetadataQuery();
	return SqlFunctions.isTrue(mq.areColumnsUnique(input, aggregate.getGroupSet()));
}
 
Example 3
Source File: SqlMinMaxAggFunction.java    From Bats with Apache License 2.0 4 votes vote down vote up
@Deprecated // to be removed before 2.0
public boolean isMin() {
  return kind == SqlKind.MIN;
}
 
Example 4
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private static boolean isAggregation(SqlKind kind) {
	return kind == SqlKind.SUM || kind == SqlKind.SUM0
		|| kind == SqlKind.AVG || kind == SqlKind.COUNT
		|| kind == SqlKind.MAX || kind == SqlKind.MIN;
}
 
Example 5
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 4 votes vote down vote up
private static boolean isAggregation(SqlKind kind) {
	return kind == SqlKind.SUM || kind == SqlKind.SUM0
		|| kind == SqlKind.AVG || kind == SqlKind.COUNT
		|| kind == SqlKind.MAX || kind == SqlKind.MIN;
}
 
Example 6
Source File: SqlMinMaxAggFunction.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Deprecated // to be removed before 2.0
public boolean isMin() {
  return kind == SqlKind.MIN;
}