Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package org.apache.flink.api.table.plan.rules.dataSet

import org.apache.calcite.plan.{Convention, RelOptRule, RelTraitSet}
import org.apache.calcite.plan.{RelOptRuleCall, Convention, RelOptRule, RelTraitSet}
import org.apache.calcite.rel.RelNode
import org.apache.calcite.rel.convert.ConverterRule
import org.apache.calcite.rel.logical.LogicalUnion
Expand All @@ -32,21 +32,29 @@ class DataSetUnionRule
"FlinkUnionRule")
{

def convert(rel: RelNode): RelNode = {
/**
* Only translate UNION ALL
*/
override def matches(call: RelOptRuleCall): Boolean = {
val union: LogicalUnion = call.rel(0).asInstanceOf[LogicalUnion]
union.all
}

def convert(rel: RelNode): RelNode = {

val union: LogicalUnion = rel.asInstanceOf[LogicalUnion]
val traitSet: RelTraitSet = rel.getTraitSet.replace(DataSetConvention.INSTANCE)
val convLeft: RelNode = RelOptRule.convert(union.getInput(0), DataSetConvention.INSTANCE)
val convRight: RelNode = RelOptRule.convert(union.getInput(1), DataSetConvention.INSTANCE)
val union: LogicalUnion = rel.asInstanceOf[LogicalUnion]
val traitSet: RelTraitSet = rel.getTraitSet.replace(DataSetConvention.INSTANCE)
val convLeft: RelNode = RelOptRule.convert(union.getInput(0), DataSetConvention.INSTANCE)
val convRight: RelNode = RelOptRule.convert(union.getInput(1), DataSetConvention.INSTANCE)

new DataSetUnion(
rel.getCluster,
traitSet,
convLeft,
convRight,
rel.getRowType)
}
new DataSetUnion(
rel.getCluster,
traitSet,
convLeft,
convRight,
rel.getRowType)
}
}

object DataSetUnionRule {
val INSTANCE: RelOptRule = new DataSetUnionRule
Expand Down