Java Code Examples for org.apache.calcite.rel.core.RelFactories#DEFAULT_FILTER_FACTORY

The following examples show how to use org.apache.calcite.rel.core.RelFactories#DEFAULT_FILTER_FACTORY . 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: SemiJoinFilterTransposeRule.java    From Bats with Apache License 2.0 6 votes vote down vote up
public void onMatch(RelOptRuleCall call) {
  SemiJoin semiJoin = call.rel(0);
  LogicalFilter filter = call.rel(1);

  RelNode newSemiJoin =
      SemiJoin.create(filter.getInput(),
          semiJoin.getRight(),
          semiJoin.getCondition(),
          semiJoin.getLeftKeys(),
          semiJoin.getRightKeys());

  final RelFactories.FilterFactory factory =
      RelFactories.DEFAULT_FILTER_FACTORY;
  RelNode newFilter =
      factory.createFilter(newSemiJoin, filter.getCondition());

  call.transformTo(newFilter);
}
 
Example 2
Source File: FlinkSemiAntiJoinFilterTransposeRule.java    From flink with Apache License 2.0 6 votes vote down vote up
public void onMatch(RelOptRuleCall call) {
	LogicalJoin join = call.rel(0);
	LogicalFilter filter = call.rel(1);

	RelNode newJoin = LogicalJoin.create(
			filter.getInput(),
			join.getRight(),
			join.getCondition(),
			join.getVariablesSet(),
			join.getJoinType());

	final RelFactories.FilterFactory factory =
			RelFactories.DEFAULT_FILTER_FACTORY;
	RelNode newFilter =
			factory.createFilter(newJoin, filter.getCondition());

	call.transformTo(newFilter);
}
 
Example 3
Source File: FlinkSemiAntiJoinFilterTransposeRule.java    From flink with Apache License 2.0 6 votes vote down vote up
public void onMatch(RelOptRuleCall call) {
	LogicalJoin join = call.rel(0);
	LogicalFilter filter = call.rel(1);

	RelNode newJoin = LogicalJoin.create(
			filter.getInput(),
			join.getRight(),
			join.getCondition(),
			join.getVariablesSet(),
			join.getJoinType());

	final RelFactories.FilterFactory factory =
			RelFactories.DEFAULT_FILTER_FACTORY;
	RelNode newFilter =
			factory.createFilter(newJoin, filter.getCondition());

	call.transformTo(newFilter);
}
 
Example 4
Source File: SemiJoinFilterTransposeRule.java    From calcite with Apache License 2.0 6 votes vote down vote up
public void onMatch(RelOptRuleCall call) {
  LogicalJoin semiJoin = call.rel(0);
  LogicalFilter filter = call.rel(1);

  RelNode newSemiJoin =
      LogicalJoin.create(filter.getInput(),
          semiJoin.getRight(),
          // No need to copy the hints, the framework would try to do that.
          ImmutableList.of(),
          semiJoin.getCondition(),
          ImmutableSet.of(),
          JoinRelType.SEMI);

  final RelFactories.FilterFactory factory =
      RelFactories.DEFAULT_FILTER_FACTORY;
  RelNode newFilter =
      factory.createFilter(newSemiJoin, filter.getCondition(),
          ImmutableSet.of());

  call.transformTo(newFilter);
}
 
Example 5
Source File: RelOptUtil.java    From Bats with Apache License 2.0 5 votes vote down vote up
@Deprecated // to be removed before 2.0
public static RelNode createNullFilter(RelNode rel, Integer[] fieldOrdinals) {
    RexNode condition = null;
    final RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
    RelDataType rowType = rel.getRowType();
    int n;
    if (fieldOrdinals != null) {
        n = fieldOrdinals.length;
    } else {
        n = rowType.getFieldCount();
    }
    List<RelDataTypeField> fields = rowType.getFieldList();
    for (int i = 0; i < n; ++i) {
        int iField;
        if (fieldOrdinals != null) {
            iField = fieldOrdinals[i];
        } else {
            iField = i;
        }
        RelDataType type = fields.get(iField).getType();
        if (!type.isNullable()) {
            continue;
        }
        RexNode newCondition = rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL,
                rexBuilder.makeInputRef(type, iField));
        if (condition == null) {
            condition = newCondition;
        } else {
            condition = rexBuilder.makeCall(SqlStdOperatorTable.AND, condition, newCondition);
        }
    }
    if (condition == null) {
        // no filtering required
        return rel;
    }

    final RelFactories.FilterFactory factory = RelFactories.DEFAULT_FILTER_FACTORY;
    return factory.createFilter(rel, condition);
}
 
Example 6
Source File: RelOptUtil.java    From Bats with Apache License 2.0 4 votes vote down vote up
@Deprecated // to be removed before 2.0
public static RelNode createFilter(RelNode child, RexNode condition) {
    final RelFactories.FilterFactory factory = RelFactories.DEFAULT_FILTER_FACTORY;
    return factory.createFilter(child, condition);
}
 
Example 7
Source File: RelOptUtil.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Deprecated // to be removed before 2.0
public static RelNode createFilter(RelNode child, RexNode condition) {
  final RelFactories.FilterFactory factory =
      RelFactories.DEFAULT_FILTER_FACTORY;
  return factory.createFilter(child, condition, ImmutableSet.of());
}
 
Example 8
Source File: RelOptUtil.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Deprecated // to be removed before 2.0
public static RelNode createNullFilter(
    RelNode rel,
    Integer[] fieldOrdinals) {
  RexNode condition = null;
  final RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
  RelDataType rowType = rel.getRowType();
  int n;
  if (fieldOrdinals != null) {
    n = fieldOrdinals.length;
  } else {
    n = rowType.getFieldCount();
  }
  List<RelDataTypeField> fields = rowType.getFieldList();
  for (int i = 0; i < n; ++i) {
    int iField;
    if (fieldOrdinals != null) {
      iField = fieldOrdinals[i];
    } else {
      iField = i;
    }
    RelDataType type = fields.get(iField).getType();
    if (!type.isNullable()) {
      continue;
    }
    RexNode newCondition =
        rexBuilder.makeCall(
            SqlStdOperatorTable.IS_NOT_NULL,
            rexBuilder.makeInputRef(type, iField));
    if (condition == null) {
      condition = newCondition;
    } else {
      condition =
          rexBuilder.makeCall(
              SqlStdOperatorTable.AND,
              condition,
              newCondition);
    }
  }
  if (condition == null) {
    // no filtering required
    return rel;
  }

  final RelFactories.FilterFactory factory =
      RelFactories.DEFAULT_FILTER_FACTORY;
  return factory.createFilter(rel, condition, ImmutableSet.of());
}