flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From KurtYoung <...@git.apache.org>
Subject [GitHub] flink pull request #3594: [FLINK-6149] [table] Add additional flink logical ...
Date Tue, 18 Apr 2017 02:13:49 GMT
Github user KurtYoung commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3594#discussion_r111858923
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/rel/logical/FlinkLogicalAggregate.scala
---
    @@ -0,0 +1,92 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.flink.table.rel.logical
    +
    +import java.util.{List => JList}
    +
    +import org.apache.calcite.plan._
    +import org.apache.calcite.rel.RelNode
    +import org.apache.calcite.rel.convert.ConverterRule
    +import org.apache.calcite.rel.core.{Aggregate, AggregateCall}
    +import org.apache.calcite.rel.logical.LogicalAggregate
    +import org.apache.calcite.rel.metadata.RelMetadataQuery
    +import org.apache.calcite.util.ImmutableBitSet
    +import org.apache.flink.table.rel.FlinkConventions
    +
    +class FlinkLogicalAggregate(
    +    cluster: RelOptCluster,
    +    traitSet: RelTraitSet,
    +    child: RelNode,
    +    indicator: Boolean,
    +    groupSet: ImmutableBitSet,
    +    groupSets: JList[ImmutableBitSet],
    +    aggCalls: JList[AggregateCall])
    +  extends Aggregate(cluster, traitSet, child, indicator, groupSet, groupSets, aggCalls)
    +  with FlinkLogicalRel {
    +
    +  override def copy(
    +      traitSet: RelTraitSet,
    +      input: RelNode,
    +      indicator: Boolean,
    +      groupSet: ImmutableBitSet,
    +      groupSets: JList[ImmutableBitSet],
    +      aggCalls: JList[AggregateCall]): Aggregate = {
    +    new FlinkLogicalAggregate(cluster, traitSet, input, indicator, groupSet, groupSets,
aggCalls)
    +  }
    +
    +  override def computeSelfCost(planner: RelOptPlanner, metadata: RelMetadataQuery): RelOptCost
= {
    +    val child = this.getInput
    +    val rowCnt = metadata.getRowCount(child)
    +    val rowSize = this.estimateRowSize(child.getRowType)
    +    val aggCnt = this.aggCalls.size
    +    planner.getCostFactory.makeCost(rowCnt, rowCnt * aggCnt, rowCnt * rowSize)
    +  }
    +}
    +
    +private class FlinkLogicalAggregateConverter
    +  extends ConverterRule(
    +    classOf[LogicalAggregate],
    +    Convention.NONE,
    +    FlinkConventions.LOGICAL,
    +    "FlinkLogicalAggregateConverter") {
    +
    +  override def matches(call: RelOptRuleCall): Boolean = {
    +    val agg = call.rel(0).asInstanceOf[LogicalAggregate]
    +    !agg.containsDistinctCall()
    --- End diff --
    
    This is similar with `FlinkLogicalJoin`, we need other logical rules to rewrite distinct
aggregates first and then convert it to a "clean" FlinkLogicalAggregate. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message