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

The following examples show how to use org.apache.calcite.rel.logical.LogicalAggregate#getCluster() . 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: 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 6
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());
}