Java Code Examples for org.apache.calcite.rel.logical.LogicalAggregate#getGroupSet()

The following examples show how to use org.apache.calcite.rel.logical.LogicalAggregate#getGroupSet() . 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: OLAPAggregateRule.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public RelNode convert(RelNode rel) {
    LogicalAggregate agg = (LogicalAggregate) rel;

    // AVG() will be transformed into SUM()/COUNT() by AggregateReduceFunctionsRule.
    // Here only let the transformed plan pass.
    if (containsAvg(agg)) {
        return null;
    }

    RelTraitSet traitSet = agg.getTraitSet().replace(OLAPRel.CONVENTION);
    try {
        return new OLAPAggregateRel(agg.getCluster(), traitSet, convert(agg.getInput(), OLAPRel.CONVENTION), agg.indicator, agg.getGroupSet(), agg.getGroupSets(), agg.getAggCallList());
    } catch (InvalidRelException e) {
        throw new IllegalStateException("Can't create OLAPAggregateRel!", e);
    }
}
 
Example 2
Source File: ElasticsearchAggregateRule.java    From dk-fitting with Apache License 2.0 6 votes vote down vote up
public RelNode convert(RelNode relNode) {
    LogicalAggregate aggregate = (LogicalAggregate) relNode;
    RelTraitSet traitSet = aggregate.getTraitSet().replace(getOutTrait());
    for (AggregateCall call : aggregate.getAggCallList())
    {
        switch (call.getAggregation().getKind())
        {
            case MIN:
            case MAX:
            case COUNT:
            case SUM:
            case AVG:break;
            default:return null;//doesn't match. aggregate rule doesn't fire
        }
    }
    return new ElasticsearchAggregate(aggregate.getCluster(), traitSet,
            convert(aggregate.getInput(), getOutTrait()), aggregate.indicator,
            aggregate.getGroupSet(), aggregate.getGroupSets(), aggregate.getAggCallList());
}
 
Example 3
Source File: ElasticsearchAggregateRule.java    From dk-fitting with Apache License 2.0 6 votes vote down vote up
public RelNode convert(RelNode relNode) {
    LogicalAggregate aggregate = (LogicalAggregate) relNode;
    RelTraitSet traitSet = aggregate.getTraitSet().replace(getOutTrait());
    for (AggregateCall call : aggregate.getAggCallList())
    {
        switch (call.getAggregation().getKind())
        {
            case MIN:
            case MAX:
            case COUNT:
            case SUM:
            case AVG:break;
            default:return null;//doesn't match. aggregate rule doesn't fire
        }
    }
    return new ElasticsearchAggregate(aggregate.getCluster(), traitSet,
            convert(aggregate.getInput(), getOutTrait()), aggregate.indicator,
            aggregate.getGroupSet(), aggregate.getGroupSets(), aggregate.getAggCallList());
}
 
Example 4
Source File: OLAPAggregateRule.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Override
public RelNode convert(RelNode rel) {
    LogicalAggregate agg = (LogicalAggregate) rel;

    // AVG() will be transformed into SUM()/COUNT() by AggregateReduceFunctionsRule.
    // Here only let the transformed plan pass.
    if (containsAvg(agg)) {
        return null;
    }

    RelTraitSet traitSet = agg.getTraitSet().replace(OLAPRel.CONVENTION);
    try {
        return new OLAPAggregateRel(agg.getCluster(), traitSet, convert(agg.getInput(), OLAPRel.CONVENTION), agg.indicator, agg.getGroupSet(), agg.getGroupSets(), agg.getAggCallList());
    } catch (InvalidRelException e) {
        throw new IllegalStateException("Can't create OLAPAggregateRel!", e);
    }
}
 
Example 5
Source File: MongoRules.java    From calcite with Apache License 2.0 6 votes vote down vote up
public RelNode convert(RelNode rel) {
  final LogicalAggregate agg = (LogicalAggregate) rel;
  final RelTraitSet traitSet =
      agg.getTraitSet().replace(out);
  try {
    return new MongoAggregate(
        rel.getCluster(),
        traitSet,
        convert(agg.getInput(), traitSet.simplify()),
        agg.getGroupSet(),
        agg.getGroupSets(),
        agg.getAggCallList());
  } catch (InvalidRelException e) {
    LOGGER.warn(e.toString());
    return null;
  }
}
 
Example 6
Source File: EnumerableSortedAggregateRule.java    From calcite with Apache License 2.0 6 votes vote down vote up
public RelNode convert(RelNode rel) {
  final LogicalAggregate agg = (LogicalAggregate) rel;
  if (!Aggregate.isSimple(agg)) {
    return null;
  }
  final RelTraitSet inputTraits = rel.getCluster()
      .traitSet().replace(EnumerableConvention.INSTANCE)
      .replace(
          RelCollations.of(
              ImmutableIntList.copyOf(
          agg.getGroupSet().asList())));
  final RelTraitSet selfTraits = inputTraits.replace(
      RelCollations.of(
      ImmutableIntList.identity(agg.getGroupSet().cardinality())));
  return new EnumerableSortedAggregate(
      rel.getCluster(),
      selfTraits,
      convert(agg.getInput(), inputTraits),
      agg.getGroupSet(),
      agg.getGroupSets(),
      agg.getAggCallList());
}
 
Example 7
Source File: EnumerableAggregateRule.java    From calcite with Apache License 2.0 6 votes vote down vote up
public RelNode convert(RelNode rel) {
  final LogicalAggregate agg = (LogicalAggregate) rel;
  final RelTraitSet traitSet = rel.getCluster()
      .traitSet().replace(EnumerableConvention.INSTANCE);
  try {
    return new EnumerableAggregate(
        rel.getCluster(),
        traitSet,
        convert(agg.getInput(), traitSet),
        agg.getGroupSet(),
        agg.getGroupSets(),
        agg.getAggCallList());
  } catch (InvalidRelException e) {
    EnumerableRules.LOGGER.debug(e.toString());
    return null;
  }
}
 
Example 8
Source File: CopyWithCluster.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Override
public RelNode visit(LogicalAggregate aggregate) {
  final RelNode input = aggregate.getInput().accept(this);
  return new LogicalAggregate(
    cluster,
    copyOf(aggregate.getTraitSet()),
    input,
    aggregate.indicator,
    aggregate.getGroupSet(),
    aggregate.getGroupSets(),
    copyOf(aggregate.getAggCallList())
  );
}
 
Example 9
Source File: SolrRules.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public RelNode convert(RelNode rel) {
  final LogicalAggregate agg = (LogicalAggregate) rel;
  final RelTraitSet traitSet = agg.getTraitSet().replace(out);
  return new SolrAggregate(
      rel.getCluster(),
      traitSet,
      convert(agg.getInput(), traitSet.simplify()),
      agg.indicator,
      agg.getGroupSet(),
      agg.getGroupSets(),
      agg.getAggCallList());
}
 
Example 10
Source File: GeodeRules.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Override public RelNode convert(RelNode rel) {
  final LogicalAggregate aggregate = (LogicalAggregate) rel;
  final RelTraitSet traitSet = aggregate.getTraitSet().replace(out);
  return new GeodeAggregate(
      aggregate.getCluster(),
      traitSet,
      convert(aggregate.getInput(), traitSet.simplify()),
      aggregate.getGroupSet(),
      aggregate.getGroupSets(),
      aggregate.getAggCallList());
}
 
Example 11
Source File: ElasticsearchRules.java    From calcite with Apache License 2.0 5 votes vote down vote up
public RelNode convert(RelNode rel) {
  final LogicalAggregate agg = (LogicalAggregate) rel;
  final RelTraitSet traitSet = agg.getTraitSet().replace(out);
  try {
    return new ElasticsearchAggregate(
        rel.getCluster(),
        traitSet,
        convert(agg.getInput(), traitSet.simplify()),
        agg.getGroupSet(),
        agg.getGroupSets(),
        agg.getAggCallList());
  } catch (InvalidRelException e) {
    return null;
  }
}
 
Example 12
Source File: Bindables.java    From calcite with Apache License 2.0 5 votes vote down vote up
public RelNode convert(RelNode rel) {
  final LogicalAggregate agg = (LogicalAggregate) rel;
  final RelTraitSet traitSet =
      agg.getTraitSet().replace(BindableConvention.INSTANCE);
  try {
    return new BindableAggregate(rel.getCluster(), traitSet,
        convert(agg.getInput(), traitSet), false, agg.getGroupSet(),
        agg.getGroupSets(), agg.getAggCallList());
  } catch (InvalidRelException e) {
    RelOptPlanner.LOGGER.debug(e.toString());
    return null;
  }
}
 
Example 13
Source File: PigRules.java    From calcite with Apache License 2.0 4 votes vote down vote up
public RelNode convert(RelNode rel) {
  final LogicalAggregate agg = (LogicalAggregate) rel;
  final RelTraitSet traitSet = agg.getTraitSet().replace(PigRel.CONVENTION);
  return new PigAggregate(agg.getCluster(), traitSet, agg.getInput(),
      agg.getGroupSet(), agg.getGroupSets(), agg.getAggCallList());
}