flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaoxuan-wang <...@git.apache.org>
Subject [GitHub] flink pull request #4471: [FLINK-6094] [table] Implement stream-stream proct...
Date Tue, 26 Sep 2017 03:48:48 GMT
Github user shaoxuan-wang commented on a diff in the pull request:

    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/rules/datastream/DataStreamJoinRule.scala
    @@ -0,0 +1,93 @@
    + * 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.plan.rules.datastream
    +import org.apache.calcite.plan.{RelOptRule, RelOptRuleCall, RelTraitSet}
    +import org.apache.calcite.rel.RelNode
    +import org.apache.calcite.rel.convert.ConverterRule
    +import org.apache.flink.table.api.TableConfig
    +import org.apache.flink.table.calcite.FlinkTypeFactory
    +import org.apache.flink.table.plan.nodes.FlinkConventions
    +import org.apache.flink.table.plan.nodes.datastream.DataStreamJoin
    +import org.apache.flink.table.plan.nodes.logical.FlinkLogicalJoin
    +import org.apache.flink.table.plan.schema.RowSchema
    +import org.apache.flink.table.runtime.join.WindowJoinUtil
    +import scala.collection.JavaConverters._
    +class DataStreamJoinRule
    +  extends ConverterRule(
    +    classOf[FlinkLogicalJoin],
    +    FlinkConventions.LOGICAL,
    +    FlinkConventions.DATASTREAM,
    +    "DataStreamJoinRule") {
    +  override def matches(call: RelOptRuleCall): Boolean = {
    +    val join: FlinkLogicalJoin = call.rel(0).asInstanceOf[FlinkLogicalJoin]
    +    val joinInfo = join.analyzeCondition
    +    val (windowBounds, remainingPreds) = WindowJoinUtil.extractWindowBoundsFromPredicate(
    +      joinInfo.getRemaining(join.getCluster.getRexBuilder),
    +      join.getLeft.getRowType.getFieldCount,
    +      join.getRowType,
    +      join.getCluster.getRexBuilder,
    +      TableConfig.DEFAULT)
    +    // remaining predicate must not access time attributes
    +    val remainingPredsAccessTime = remainingPreds.isDefined &&
    +      WindowJoinUtil.accessesTimeAttribute(remainingPreds.get, join.getRowType)
    +    // Check that no event-time attributes are in the input.
    +    val rowTimeAttrInOutput = join.getRowType.getFieldList.asScala
    +      .exists(f => FlinkTypeFactory.isRowtimeIndicatorType(f.getType))
    +    if (!windowBounds.isDefined && !remainingPredsAccessTime && !rowTimeAttrInOutput)
    --- End diff --
    @fhueske, we actually agree quite a lot on the concern of infinite size you have raised.
The same problem does not only exist in joining, but also in other cases, for example GROUPBY,
where the grouping-key and associated state can be unlimited in terms of the size that the
state of Flink can not hold them all. IMO, there is not an easy way to completely eliminate
this just through the validation of query planner/optimizer, so I think it is not a good idea
to only allow the unbounded-joining after a certain operators, like non-windowed aggregation
(in fact, as mentioned above, the grouping-key of aggregation may also be infinite, so this
does not ensure the finite state for joining operator). 
    On the other hand, I think the finite state can only be ensured by the users by giving
some hints/controls. We need instruct users to properly set those control knobs, such that
their jobs will not run out of space. One hint we currently have is state ttl. (I think @hequn8128
has already added this for this unbounded joining). Maybe here we can add a check on state
ttl to force users set a proper value. What do you think?


View raw message