Search in sources :

Example 1 with FlinkLogicalTableAggregate

use of org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalTableAggregate in project flink by apache.

the class StreamPhysicalPythonGroupTableAggregateRule method matches.

@Override
public boolean matches(RelOptRuleCall call) {
    FlinkLogicalTableAggregate agg = call.rel(0);
    List<AggregateCall> aggCalls = agg.getAggCallList();
    boolean existGeneralPythonFunction = aggCalls.stream().anyMatch(x -> PythonUtil.isPythonAggregate(x, PythonFunctionKind.GENERAL));
    boolean existPandasFunction = aggCalls.stream().anyMatch(x -> PythonUtil.isPythonAggregate(x, PythonFunctionKind.PANDAS));
    boolean existJavaUserDefinedFunction = aggCalls.stream().anyMatch(x -> !PythonUtil.isPythonAggregate(x, null) && !PythonUtil.isBuiltInAggregate(x));
    if (existPandasFunction || existGeneralPythonFunction) {
        if (existPandasFunction) {
            throw new TableException("Pandas UDAFs are not supported in streaming mode currently.");
        }
        if (existJavaUserDefinedFunction) {
            throw new TableException("Python UDAF and Java/Scala UDAF cannot be used together.");
        }
        return true;
    } else {
        return false;
    }
}
Also used : AggregateCall(org.apache.calcite.rel.core.AggregateCall) TableException(org.apache.flink.table.api.TableException) FlinkLogicalTableAggregate(org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalTableAggregate)

Example 2 with FlinkLogicalTableAggregate

use of org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalTableAggregate in project flink by apache.

the class RelTimeIndicatorConverter method visitTableAggregate.

private RelNode visitTableAggregate(FlinkLogicalTableAggregate tableAgg) {
    FlinkLogicalAggregate correspondingAgg = FlinkLogicalAggregate.create(tableAgg.getInput(), tableAgg.getGroupSet(), tableAgg.getGroupSets(), tableAgg.getAggCallList());
    FlinkLogicalAggregate convertedAgg = visitAggregate(correspondingAgg);
    return new FlinkLogicalTableAggregate(tableAgg.getCluster(), tableAgg.getTraitSet(), convertedAgg.getInput(), convertedAgg.getGroupSet(), convertedAgg.getGroupSets(), convertedAgg.getAggCallList());
}
Also used : FlinkLogicalTableAggregate(org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalTableAggregate) FlinkLogicalAggregate(org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalAggregate)

Example 3 with FlinkLogicalTableAggregate

use of org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalTableAggregate in project flink by apache.

the class StreamPhysicalPythonGroupTableAggregateRule method convert.

@Override
public RelNode convert(RelNode rel) {
    FlinkLogicalTableAggregate agg = (FlinkLogicalTableAggregate) rel;
    FlinkRelDistribution requiredDistribution;
    if (agg.getGroupSet().cardinality() != 0) {
        requiredDistribution = FlinkRelDistribution.hash(agg.getGroupSet().asList(), true);
    } else {
        requiredDistribution = FlinkRelDistribution.SINGLETON();
    }
    RelTraitSet requiredTraitSet = rel.getCluster().getPlanner().emptyTraitSet().replace(requiredDistribution).replace(FlinkConventions.STREAM_PHYSICAL());
    RelTraitSet providedTraitSet = rel.getTraitSet().replace(FlinkConventions.STREAM_PHYSICAL());
    RelNode newInput = RelOptRule.convert(agg.getInput(), requiredTraitSet);
    return new StreamPhysicalPythonGroupTableAggregate(rel.getCluster(), providedTraitSet, newInput, rel.getRowType(), agg.getGroupSet().toArray(), JavaScalaConversionUtil.toScala(agg.getAggCallList()));
}
Also used : StreamPhysicalPythonGroupTableAggregate(org.apache.flink.table.planner.plan.nodes.physical.stream.StreamPhysicalPythonGroupTableAggregate) FlinkRelDistribution(org.apache.flink.table.planner.plan.trait.FlinkRelDistribution) FlinkLogicalTableAggregate(org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalTableAggregate) RelNode(org.apache.calcite.rel.RelNode) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Aggregations

FlinkLogicalTableAggregate (org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalTableAggregate)3 RelTraitSet (org.apache.calcite.plan.RelTraitSet)1 RelNode (org.apache.calcite.rel.RelNode)1 AggregateCall (org.apache.calcite.rel.core.AggregateCall)1 TableException (org.apache.flink.table.api.TableException)1 FlinkLogicalAggregate (org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalAggregate)1 StreamPhysicalPythonGroupTableAggregate (org.apache.flink.table.planner.plan.nodes.physical.stream.StreamPhysicalPythonGroupTableAggregate)1 FlinkRelDistribution (org.apache.flink.table.planner.plan.trait.FlinkRelDistribution)1