Java Code Examples for org.apache.calcite.rel.logical.LogicalFilter#getCluster()

The following examples show how to use org.apache.calcite.rel.logical.LogicalFilter#getCluster() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubstitutionVisitor.java    From Bats with Apache License 2.0 6 votes vote down vote up
@Override
public void onMatch(RelOptRuleCall call) {
    final LogicalFilter filter = call.rel(0);
    final LogicalProject project = call.rel(1);

    final List<RexNode> newProjects = new ArrayList<>(project.getProjects());
    newProjects.add(filter.getCondition());

    final RelOptCluster cluster = filter.getCluster();
    RelDataType newRowType = cluster.getTypeFactory().builder().addAll(project.getRowType().getFieldList())
            .add("condition", Util.last(newProjects).getType()).build();
    final RelNode newProject = project.copy(project.getTraitSet(), project.getInput(), newProjects, newRowType);

    final RexInputRef newCondition = cluster.getRexBuilder().makeInputRef(newProject, newProjects.size() - 1);

    call.transformTo(LogicalFilter.create(newProject, newCondition));
}
 
Example 2
Source File: OLAPFilterRule.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public RelNode convert(RelNode rel) {
    LogicalFilter filter = (LogicalFilter) rel;

    RelTraitSet origTraitSet = filter.getTraitSet();
    RelTraitSet traitSet = origTraitSet.replace(OLAPRel.CONVENTION).simplify();

    return new OLAPFilterRel(filter.getCluster(), traitSet,
            convert(filter.getInput(), filter.getInput().getTraitSet().replace(OLAPRel.CONVENTION)),
            filter.getCondition());
}
 
Example 3
Source File: OLAPFilterRule.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Override
public RelNode convert(RelNode rel) {
    LogicalFilter filter = (LogicalFilter) rel;

    RelTraitSet origTraitSet = filter.getTraitSet();
    RelTraitSet traitSet = origTraitSet.replace(OLAPRel.CONVENTION).simplify();

    return new OLAPFilterRel(filter.getCluster(), traitSet,
            convert(filter.getInput(), filter.getInput().getTraitSet().replace(OLAPRel.CONVENTION)),
            filter.getCondition());
}
 
Example 4
Source File: GeodeRules.java    From calcite with Apache License 2.0 5 votes vote down vote up
private RelNode convert(LogicalFilter filter, GeodeTableScan scan) {
  final RelTraitSet traitSet = filter.getTraitSet().replace(GeodeRel.CONVENTION);
  return new GeodeFilter(
      filter.getCluster(),
      traitSet,
      convert(filter.getInput(), GeodeRel.CONVENTION),
      filter.getCondition());
}
 
Example 5
Source File: CassandraRules.java    From calcite with Apache License 2.0 5 votes vote down vote up
public RelNode convert(LogicalFilter filter, CassandraTableScan scan) {
  final RelTraitSet traitSet = filter.getTraitSet().replace(CassandraRel.CONVENTION);
  final Pair<List<String>, List<String>> keyFields = scan.cassandraTable.getKeyFields();
  return new CassandraFilter(
      filter.getCluster(),
      traitSet,
      convert(filter.getInput(), CassandraRel.CONVENTION),
      filter.getCondition(),
      keyFields.left,
      keyFields.right,
      scan.cassandraTable.getClusteringOrder());
}