org.apache.calcite.rel.core.Aggregate.getGroupType()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中org.apache.calcite.rel.core.Aggregate.getGroupType()方法的一些代码示例,展示了Aggregate.getGroupType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Aggregate.getGroupType()方法的具体详情如下:
包路径:org.apache.calcite.rel.core.Aggregate
类名称:Aggregate
方法名:getGroupType

Aggregate.getGroupType介绍

[英]Returns the type of roll-up.
[中]

代码示例

代码示例来源:origin: apache/kylin

@Override
  public boolean apply(@Nullable Aggregate input) {
    return input.getGroupType() != Aggregate.Group.SIMPLE;
  }
}, operand(RelNode.class, any())), "AggregateMultipleExpandRule");

代码示例来源:origin: apache/hive

@Override
public boolean matches(RelOptRuleCall call) {
 final Aggregate aggregate = call.rel(0);
 // Rule cannot be applied if there are GroupingSets
 if (aggregate.getGroupType() != Group.SIMPLE) {
  return false;
 }
 return super.matches(call);
}

代码示例来源:origin: apache/hive

if (a.getGroupType() != Group.SIMPLE) {

代码示例来源:origin: apache/hive

public RelNode align(Aggregate rel, List<RelFieldCollation> collations) {
 // 1) We extract the group by positions that are part of the collations and
 // sort them so they respect it
 LinkedHashSet<Integer> aggregateColumnsOrder = new LinkedHashSet<>();
 ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
 if (rel.getGroupType() == Group.SIMPLE && !collations.isEmpty()) {
  for (RelFieldCollation c : collations) {
   if (c.getFieldIndex() < rel.getGroupCount()) {
    // Group column found
    if (aggregateColumnsOrder.add(c.getFieldIndex())) {
     propagateCollations.add(c.copy(rel.getGroupSet().nth(c.getFieldIndex())));
    }
   }
  }
 }
 for (int i = 0; i < rel.getGroupCount(); i++) {
  if (!aggregateColumnsOrder.contains(i)) {
   // Not included in the input collations, but can be propagated as this Aggregate
   // will enforce it
   propagateCollations.add(new RelFieldCollation(rel.getGroupSet().nth(i)));
  }
 }
 // 2) We propagate
 final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
 // 3) We annotate the Aggregate operator with this info
 final HiveAggregate newAggregate = (HiveAggregate) rel.copy(rel.getTraitSet(),
     ImmutableList.of(child));
 newAggregate.setAggregateColumnsOrder(aggregateColumnsOrder);
 return newAggregate;
}

代码示例来源:origin: apache/hive

if (rel.getGroupType() != Aggregate.Group.SIMPLE) {
 throw new AssertionError(Bug.CALCITE_461_FIXED);

代码示例来源:origin: apache/hive

if(rightAggregate.getGroupType() != Aggregate.Group.SIMPLE) {
 return;

代码示例来源:origin: apache/hive

ASTBuilder b;
boolean groupingSetsExpression = false;
Group aggregateType = groupBy.getGroupType();
switch (aggregateType) {
 case SIMPLE:

代码示例来源:origin: Qihoo360/Quicksql

/**
 * @see org.apache.calcite.util.Bug#CALCITE_461_FIXED
 */
public static boolean isSimple(Aggregate aggregate) {
 return aggregate.getGroupType() == Group.SIMPLE;
}

代码示例来源:origin: org.apache.calcite/calcite-core

/**
 * @see org.apache.calcite.util.Bug#CALCITE_461_FIXED
 */
public static boolean isSimple(Aggregate aggregate) {
 return aggregate.getGroupType() == Group.SIMPLE;
}

代码示例来源:origin: org.apache.kylin/kylin-query

@Override
  public boolean apply(@Nullable Aggregate input) {
    return input.getGroupType() != Aggregate.Group.SIMPLE;
  }
}, operand(RelNode.class, any())), "AggregateMultipleExpandRule");

代码示例来源:origin: org.apache.calcite/calcite-core

@Override protected boolean isValidPlan(Project topProject, RelNode node,
  RelMetadataQuery mq) {
 if (!(node instanceof Aggregate)) {
  return false;
 }
 Aggregate aggregate = (Aggregate) node;
 if (aggregate.getGroupType() != Aggregate.Group.SIMPLE) {
  // TODO: Rewriting with grouping sets not supported yet
  return false;
 }
 return isValidRelNodePlan(aggregate.getInput(), mq);
}

代码示例来源:origin: Qihoo360/Quicksql

@Override protected boolean isValidPlan(Project topProject, RelNode node,
  RelMetadataQuery mq) {
 if (!(node instanceof Aggregate)) {
  return false;
 }
 Aggregate aggregate = (Aggregate) node;
 if (aggregate.getGroupType() != Aggregate.Group.SIMPLE) {
  // TODO: Rewriting with grouping sets not supported yet
  return false;
 }
 return isValidRelNodePlan(aggregate.getInput(), mq);
}

代码示例来源:origin: com.alibaba.blink/flink-table

/** Creates an FlinkAggregateJoinTransposeRule. */
public FlinkAggregateJoinTransposeRule(Class<? extends Aggregate> aggregateClass,
    Class<? extends Join> joinClass, RelBuilderFactory relBuilderFactory,
    boolean allowFunctions, boolean allowLeftOrRightOuterJoin) {
  super(
      operandJ(aggregateClass, null,
          aggregate -> aggregate.getGroupType() == Aggregate.Group.SIMPLE,
          operand(joinClass, any())),
      relBuilderFactory, null);
  this.allowFunctions = allowFunctions;
  this.allowLeftOrRightOuterJoin = allowLeftOrRightOuterJoin;
}

代码示例来源:origin: Qihoo360/Quicksql

/** Creates an AggregateJoinTransposeRule. */
public AggregateJoinTransposeRule(Class<? extends Aggregate> aggregateClass,
  Class<? extends Join> joinClass, RelBuilderFactory relBuilderFactory,
  boolean allowFunctions) {
 super(
   operandJ(aggregateClass, null,
     aggregate -> aggregate.getGroupType() == Aggregate.Group.SIMPLE,
     operand(joinClass, any())),
   relBuilderFactory, null);
 this.allowFunctions = allowFunctions;
}

代码示例来源:origin: org.apache.calcite/calcite-core

/** Creates an AggregateJoinTransposeRule. */
public AggregateJoinTransposeRule(Class<? extends Aggregate> aggregateClass,
  Class<? extends Join> joinClass, RelBuilderFactory relBuilderFactory,
  boolean allowFunctions) {
 super(
   operandJ(aggregateClass, null,
     aggregate -> aggregate.getGroupType() == Aggregate.Group.SIMPLE,
     operand(joinClass, any())),
   relBuilderFactory, null);
 this.allowFunctions = allowFunctions;
}

代码示例来源:origin: Qihoo360/Quicksql

private boolean canPush(Aggregate aggregate, ImmutableBitSet rCols) {
  // If the filter references columns not in the group key, we cannot push
  final ImmutableBitSet groupKeys =
    ImmutableBitSet.range(0, aggregate.getGroupSet().cardinality());
  if (!groupKeys.contains(rCols)) {
   return false;
  }

  if (aggregate.getGroupType() != Group.SIMPLE) {
   // If grouping sets are used, the filter can be pushed if
   // the columns referenced in the predicate are present in
   // all the grouping sets.
   for (ImmutableBitSet groupingSet : aggregate.getGroupSets()) {
    if (!groupingSet.contains(rCols)) {
     return false;
    }
   }
  }
  return true;
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

private boolean canPush(Aggregate aggregate, ImmutableBitSet rCols) {
  // If the filter references columns not in the group key, we cannot push
  final ImmutableBitSet groupKeys =
    ImmutableBitSet.range(0, aggregate.getGroupSet().cardinality());
  if (!groupKeys.contains(rCols)) {
   return false;
  }

  if (aggregate.getGroupType() != Group.SIMPLE) {
   // If grouping sets are used, the filter can be pushed if
   // the columns referenced in the predicate are present in
   // all the grouping sets.
   for (ImmutableBitSet groupingSet : aggregate.getGroupSets()) {
    if (!groupingSet.contains(rCols)) {
     return false;
    }
   }
  }
  return true;
 }
}

代码示例来源:origin: Qihoo360/Quicksql

public RelWriter explainTerms(RelWriter pw) {
 // We skip the "groups" element if it is a singleton of "group".
 super.explainTerms(pw)
   .item("group", groupSet)
   .itemIf("groups", groupSets, getGroupType() != Group.SIMPLE)
   .itemIf("indicator", indicator, indicator)
   .itemIf("aggs", aggCalls, pw.nest());
 if (!pw.nest()) {
  for (Ord<AggregateCall> ord : Ord.zip(aggCalls)) {
   pw.item(Util.first(ord.e.name, "agg#" + ord.i), ord.e);
  }
 }
 return pw;
}

代码示例来源:origin: org.apache.calcite/calcite-core

public RelWriter explainTerms(RelWriter pw) {
 // We skip the "groups" element if it is a singleton of "group".
 super.explainTerms(pw)
   .item("group", groupSet)
   .itemIf("groups", groupSets, getGroupType() != Group.SIMPLE)
   .itemIf("indicator", indicator, indicator)
   .itemIf("aggs", aggCalls, pw.nest());
 if (!pw.nest()) {
  for (Ord<AggregateCall> ord : Ord.zip(aggCalls)) {
   pw.item(Util.first(ord.e.name, "agg#" + ord.i), ord.e);
  }
 }
 return pw;
}

代码示例来源:origin: com.alibaba.blink/flink-table

@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()));
}

相关文章