/** * 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)); } }
/** Converts a call to a grouped window function to a call to its auxiliary * window function(s). 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 List<Pair<SqlNode, AuxiliaryConverter>> convertGroupToAuxiliaryCalls( SqlCall call) { final SqlOperator op = call.getOperator(); if (op instanceof SqlGroupedWindowFunction && op.isGroup()) { ImmutableList.Builder<Pair<SqlNode, AuxiliaryConverter>> builder = ImmutableList.builder(); for (final SqlGroupedWindowFunction f : ((SqlGroupedWindowFunction) op).getAuxiliaryFunctions()) { builder.add( Pair.of(copy(call, f), new AuxiliaryConverter.Impl(f))); } return builder.build(); } return ImmutableList.of(); }
/** * 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)); } }
/** Converts a call to a grouped window function to a call to its auxiliary * window function(s). 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 List<Pair<SqlNode, AuxiliaryConverter>> convertGroupToAuxiliaryCalls( SqlCall call) { final SqlOperator op = call.getOperator(); if (op instanceof SqlGroupedWindowFunction && op.isGroup()) { ImmutableList.Builder<Pair<SqlNode, AuxiliaryConverter>> builder = ImmutableList.builder(); for (final SqlGroupedWindowFunction f : ((SqlGroupedWindowFunction) op).getAuxiliaryFunctions()) { builder.add( Pair.of(copy(call, f), new AuxiliaryConverter.Impl(f))); } return builder.build(); } return ImmutableList.of(); }
/** * 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)); } }
/** Converts a call to a grouped window function to a call to its auxiliary * window function(s). 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 List<Pair<SqlNode, AuxiliaryConverter>> convertGroupToAuxiliaryCalls(SqlCall call) { final SqlOperator op = call.getOperator(); if (op instanceof SqlGroupFunction && op.isGroup()) { ImmutableList.Builder<Pair<SqlNode, AuxiliaryConverter>> builder = ImmutableList.builder(); for (final SqlGroupFunction f : ((SqlGroupFunction) op).getAuxiliaryFunctions()) { builder.add( Pair.<SqlNode, AuxiliaryConverter>of(copy(call, f), new AuxiliaryConverter.Impl(f))); } return builder.build(); } return ImmutableList.of(); }
if (group && operator.isGroup()) { return found(call);
if (group && operator.isGroup()) { return found(call);