Skip to content

Commit

Permalink
[FLINK-3735] Make DataSetUnionRule match only for union-all
Browse files Browse the repository at this point in the history
This closes apache#1874
  • Loading branch information
vasia committed Apr 13, 2016
1 parent db6528b commit 8e036c3
Showing 1 changed file with 21 additions and 13 deletions.
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

0 comments on commit 8e036c3

Please sign in to comment.