private static boolean allAggregatesHaveFilters(List<AggregateCall> calls) { for (AggregateCall call : calls) { if (!call.hasFilter()) { return false; } } return true; }
private static boolean allAggregatesHaveFilters(List<AggregateCall> calls) { for (AggregateCall call : calls) { if (!call.hasFilter()) { return false; } } return true; }
private static List<Integer> getFilterRefs(List<AggregateCall> calls) { List<Integer> refs = new ArrayList<>(); for (AggregateCall call : calls) { if (call.hasFilter()) { refs.add(call.filterArg); } } return refs; }
/** * Returns an array of unique filter references from * the given list of {@link org.apache.calcite.rel.core.AggregateCall} * */ private Set<Integer> getUniqueFilterRefs(List<AggregateCall> calls) { Set<Integer> refs = new HashSet<>(); for (AggregateCall call : calls) { if (call.hasFilter()) { refs.add(call.filterArg); } } return refs; }
private static List<Integer> getFilterRefs(List<AggregateCall> calls) { List<Integer> refs = new ArrayList<>(); for (AggregateCall call : calls) { if (call.hasFilter()) { refs.add(call.filterArg); } } return refs; }
/** * Returns an array of unique filter references from * the given list of {@link org.apache.calcite.rel.core.AggregateCall} * */ private Set<Integer> getUniqueFilterRefs(List<AggregateCall> calls) { Set<Integer> refs = new HashSet<>(); for (AggregateCall call : calls) { if (call.hasFilter()) { refs.add(call.filterArg); } } return refs; }
public String toString() { StringBuilder buf = new StringBuilder(aggFunction.getName()); buf.append("("); if (distinct) { buf.append((argList.size() == 0) ? "DISTINCT" : "DISTINCT "); } int i = -1; for (Integer arg : argList) { if (++i > 0) { buf.append(", "); } buf.append("$"); buf.append(arg); } buf.append(")"); if (hasFilter()) { buf.append(" FILTER $"); buf.append(filterArg); } return buf.toString(); }
public String toString() { StringBuilder buf = new StringBuilder(aggFunction.toString()); buf.append("("); if (distinct) { buf.append((argList.size() == 0) ? "DISTINCT" : "DISTINCT "); } int i = -1; for (Integer arg : argList) { if (++i > 0) { buf.append(", "); } buf.append("$"); buf.append(arg); } buf.append(")"); if (!collation.equals(RelCollations.EMPTY)) { buf.append(" WITHIN GROUP ("); buf.append(collation); buf.append(")"); } if (hasFilter()) { buf.append(" FILTER $"); buf.append(filterArg); } return buf.toString(); }
/** Creates a copy of this aggregate call, applying a mapping to its * arguments. */ public AggregateCall transform(Mappings.TargetMapping mapping) { return copy(Mappings.apply2((Mapping) mapping, argList), hasFilter() ? Mappings.apply(mapping, filterArg) : -1); } }
/** Creates a copy of this aggregate call, applying a mapping to its * arguments. */ public AggregateCall transform(Mappings.TargetMapping mapping) { return copy(Mappings.apply2((Mapping) mapping, argList), hasFilter() ? Mappings.apply(mapping, filterArg) : -1, RelCollations.permute(collation, mapping)); } }
/** * Creates a binding of this call in the context of an * {@link org.apache.calcite.rel.logical.LogicalAggregate}, * which can then be used to infer the return type. */ public Aggregate.AggCallBinding createBinding( Aggregate aggregateRelBase) { final RelDataType rowType = aggregateRelBase.getInput().getRowType(); return new Aggregate.AggCallBinding( aggregateRelBase.getCluster().getTypeFactory(), aggFunction, SqlTypeUtil.projectTypes(rowType, argList), aggregateRelBase.getGroupCount(), hasFilter()); }
/** * Creates a binding of this call in the context of an * {@link org.apache.calcite.rel.logical.LogicalAggregate}, * which can then be used to infer the return type. */ public Aggregate.AggCallBinding createBinding( Aggregate aggregateRelBase) { final RelDataType rowType = aggregateRelBase.getInput().getRowType(); return new Aggregate.AggCallBinding( aggregateRelBase.getCluster().getTypeFactory(), aggFunction, SqlTypeUtil.projectTypes(rowType, argList), aggregateRelBase.getGroupCount(), hasFilter()); }
if (project != null && aggCall.hasFilter()) { filterNode = project.getProjects().get(aggCall.filterArg); } else {
if (aggCall.hasFilter()) { RexCall filterNode = (RexCall) projects.get(aggCall.filterArg); JsonFilter filter = translator.translateFilter(filterNode.getOperands().get(0));
if (!aggCall.hasFilter() || (uniqueFilterRefs.size() == 1 && allHaveFilters) // filters get extracted || project.getProjects().get(newFilterArg).isAlwaysTrue()) {