Java Code Examples for org.apache.calcite.sql.SqlOperator#isGroupAuxiliary()

The following examples show how to use org.apache.calcite.sql.SqlOperator#isGroupAuxiliary() . 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: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Throws an error if there is an aggregate or windowed aggregate in the
 * given clause.
 *
 * @param aggFinder Finder for the particular kind(s) of aggregate function
 * @param node      Parse tree
 * @param clause    Name of clause: "WHERE", "GROUP BY", "ON"
 */
private void validateNoAggs(AggFinder aggFinder, SqlNode node,
	String clause) {
	final SqlCall agg = aggFinder.findAgg(node);
	if (agg == null) {
		return;
	}
	final SqlOperator op = agg.getOperator();
	if (op == SqlStdOperatorTable.OVER) {
		throw newValidationError(agg,
			RESOURCE.windowedAggregateIllegalInClause(clause));
	} else if (op.isGroup() || op.isGroupAuxiliary()) {
		throw newValidationError(agg,
			RESOURCE.groupFunctionMustAppearInGroupByClause(op.getName()));
	} else {
		throw newValidationError(agg,
			RESOURCE.aggregateIllegalInClause(clause));
	}
}
 
Example 2
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Throws an error if there is an aggregate or windowed aggregate in the
 * given clause.
 *
 * @param aggFinder Finder for the particular kind(s) of aggregate function
 * @param node      Parse tree
 * @param clause    Name of clause: "WHERE", "GROUP BY", "ON"
 */
private void validateNoAggs(AggFinder aggFinder, SqlNode node,
	String clause) {
	final SqlCall agg = aggFinder.findAgg(node);
	if (agg == null) {
		return;
	}
	final SqlOperator op = agg.getOperator();
	if (op == SqlStdOperatorTable.OVER) {
		throw newValidationError(agg,
			RESOURCE.windowedAggregateIllegalInClause(clause));
	} else if (op.isGroup() || op.isGroupAuxiliary()) {
		throw newValidationError(agg,
			RESOURCE.groupFunctionMustAppearInGroupByClause(op.getName()));
	} else {
		throw newValidationError(agg,
			RESOURCE.aggregateIllegalInClause(clause));
	}
}
 
Example 3
Source File: SqlStdOperatorTable.java    From Bats with Apache License 2.0 5 votes vote down vote up
/** Converts a call to a grouped auxiliary function
 * to a call to the grouped window function. For other calls returns null.
 *
 * <p>For example, converts {@code TUMBLE_START(rowtime, INTERVAL '1' HOUR))}
 * to {@code TUMBLE(rowtime, INTERVAL '1' HOUR))}. */
public static SqlCall convertAuxiliaryToGroupCall(SqlCall call) {
  final SqlOperator op = call.getOperator();
  if (op instanceof SqlGroupedWindowFunction
      && op.isGroupAuxiliary()) {
    return copy(call, ((SqlGroupedWindowFunction) op).groupFunction);
  }
  return null;
}
 
Example 4
Source File: SqlStdOperatorTable.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** Converts a call to a grouped auxiliary function
 * to a call to the grouped window function. For other calls returns null.
 *
 * <p>For example, converts {@code TUMBLE_START(rowtime, INTERVAL '1' HOUR))}
 * to {@code TUMBLE(rowtime, INTERVAL '1' HOUR))}. */
public static SqlCall convertAuxiliaryToGroupCall(SqlCall call) {
  final SqlOperator op = call.getOperator();
  if (op instanceof SqlGroupedWindowFunction
      && op.isGroupAuxiliary()) {
    return copy(call, ((SqlGroupedWindowFunction) op).groupFunction);
  }
  return null;
}