Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/3715#discussion_r125423693 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/rules/datastream/DataStreamWindowJoinRule.scala --- @@ -20,28 +20,60 @@ 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.`type`.RelDataType import org.apache.calcite.rel.convert.ConverterRule +import org.apache.calcite.rex.RexNode +import org.apache.flink.table.api.{TableConfig, TableException} import org.apache.flink.table.plan.nodes.FlinkConventions -import org.apache.flink.table.plan.nodes.datastream.DataStreamRowStreamJoin +import org.apache.flink.table.plan.nodes.datastream.DataStreamWindowJoin import org.apache.flink.table.plan.nodes.logical.FlinkLogicalJoin import org.apache.flink.table.plan.schema.RowSchema -import org.apache.flink.table.runtime.join.JoinUtil +import org.apache.flink.table.runtime.join.WindowJoinUtil -class DataStreamRowStreamJoinRule +class DataStreamWindowJoinRule extends ConverterRule( classOf[FlinkLogicalJoin], FlinkConventions.LOGICAL, FlinkConventions.DATASTREAM, "DataStreamJoinRule") { + /** Time indicator type **/ + private var timeType: RelDataType = _ + + /** left input lower boudary **/ + private var leftLowerBoundary: Long = _ + + /** left input upper boudary **/ + private var leftUpperBoundary: Long = _ + + /** remain join condition exclude equal condition and time condition **/ + private var remainCondition: Option[RexNode] = _ + override def matches(call: RelOptRuleCall): Boolean = { val join: FlinkLogicalJoin = call.rel(0).asInstanceOf[FlinkLogicalJoin] val joinInfo = join.analyzeCondition - JoinUtil.isStreamStreamJoin( - joinInfo.getRemaining(join.getCluster.getRexBuilder), - join.getRowType) + try { + val leftRowSchema = new RowSchema(join.getLeft.getRowType) + + val result = + WindowJoinUtil.analyzeTimeBoundary( + joinInfo.getRemaining(join.getCluster.getRexBuilder), + leftRowSchema.logicalType.getFieldCount, + leftRowSchema.physicalType.getFieldCount, + join.getRowType, + join.getCluster.getRexBuilder, + TableConfig.DEFAULT) + timeType = result._1 --- End diff -- This can be done more concisely as: ``` (timeType, leftLowerBoundary, leftUpperBoundary, remainCondition) = WindowJoinUtil.analyzeTimeBoundary(...) ```
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---