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

The following examples show how to use org.apache.calcite.rel.logical.LogicalFilter#getInput() . 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: DrillFilterRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
@Override
public void onMatch(RelOptRuleCall call) {
  final LogicalFilter filter = call.rel(0);
  final RelNode input = filter.getInput();
  final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify());
  call.transformTo(new DrillFilterRel(
      filter.getCluster(), convertedInput.getTraitSet(),
      convertedInput, filter.getCondition()));
}
 
Example 2
Source File: FilterRule.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Override
public void onMatch(RelOptRuleCall call) {
  final LogicalFilter filter = (LogicalFilter) call.rel(0);
  final RelNode input = filter.getInput();
  //final RelTraitSet traits = filter.getTraitSet().plus(Rel.LOGICAL);
  final RelNode convertedInput = convert(input, input.getTraitSet().plus(Rel.LOGICAL).simplify());
  call.transformTo(new FilterRel(filter.getCluster(), convertedInput.getTraitSet(), convertedInput, filter.getCondition()));
}
 
Example 3
Source File: RelDecorrelator.java    From Bats with Apache License 2.0 4 votes vote down vote up
/**
 * Rewrite LogicalFilter.
 *
 * @param rel the filter rel to rewrite
 */
public Frame decorrelateRel(LogicalFilter rel) {
    //
    // Rewrite logic:
    //
    // 1. If a Filter references a correlated field in its filter
    // condition, rewrite the Filter to be
    // Filter
    // Join(cross product)
    // originalFilterInput
    // ValueGenerator(produces distinct sets of correlated variables)
    // and rewrite the correlated fieldAccess in the filter condition to
    // reference the Join output.
    //
    // 2. If Filter does not reference correlated variables, simply
    // rewrite the filter condition using new input.
    //

    final RelNode oldInput = rel.getInput();
    Frame frame = getInvoke(oldInput, rel);
    if (frame == null) {
        // If input has not been rewritten, do not rewrite this rel.
        return null;
    }

    // If this Filter has correlated reference, create value generator
    // and produce the correlated variables in the new output.
    if (false) {
        if (cm.mapRefRelToCorRef.containsKey(rel)) {
            frame = decorrelateInputWithValueGenerator(rel, frame);
        }
    } else {
        frame = maybeAddValueGenerator(rel, frame);
    }

    final CorelMap cm2 = new CorelMapBuilder().build(rel);

    // Replace the filter expression to reference output of the join
    // Map filter to the new filter over join
    relBuilder.push(frame.r).filter(decorrelateExpr(currentRel, map, cm2, rel.getCondition()));

    // Filter does not change the input ordering.
    // Filter rel does not permute the input.
    // All corVars produced by filter will have the same output positions in the
    // input rel.
    return register(rel, relBuilder.build(), frame.oldToNewOutputs, frame.corDefOutputs);
}
 
Example 4
Source File: RelDecorrelator.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Rewrite LogicalFilter.
 *
 * @param rel the filter rel to rewrite
 */
public Frame decorrelateRel(LogicalFilter rel) {
  //
  // Rewrite logic:
  //
  // 1. If a Filter references a correlated field in its filter
  // condition, rewrite the Filter to be
  //   Filter
  //     Join(cross product)
  //       originalFilterInput
  //       ValueGenerator(produces distinct sets of correlated variables)
  // and rewrite the correlated fieldAccess in the filter condition to
  // reference the Join output.
  //
  // 2. If Filter does not reference correlated variables, simply
  // rewrite the filter condition using new input.
  //

  final RelNode oldInput = rel.getInput();
  Frame frame = getInvoke(oldInput, rel);
  if (frame == null) {
    // If input has not been rewritten, do not rewrite this rel.
    return null;
  }

  // If this Filter has correlated reference, create value generator
  // and produce the correlated variables in the new output.
  if (false) {
    if (cm.mapRefRelToCorRef.containsKey(rel)) {
      frame = decorrelateInputWithValueGenerator(rel, frame);
    }
  } else {
    frame = maybeAddValueGenerator(rel, frame);
  }

  final CorelMap cm2 = new CorelMapBuilder().build(rel);

  // Replace the filter expression to reference output of the join
  // Map filter to the new filter over join
  relBuilder.push(frame.r)
      .filter(decorrelateExpr(currentRel, map, cm2, rel.getCondition()));

  // Filter does not change the input ordering.
  // Filter rel does not permute the input.
  // All corVars produced by filter will have the same output positions in the
  // input rel.
  return register(rel, relBuilder.build(), frame.oldToNewOutputs,
      frame.corDefOutputs);
}
 
Example 5
Source File: RelDecorrelator.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Rewrite LogicalFilter.
 *
 * @param rel the filter rel to rewrite
 */
public Frame decorrelateRel(LogicalFilter rel) {
  //
  // Rewrite logic:
  //
  // 1. If a Filter references a correlated field in its filter
  // condition, rewrite the Filter to be
  //   Filter
  //     Join(cross product)
  //       originalFilterInput
  //       ValueGenerator(produces distinct sets of correlated variables)
  // and rewrite the correlated fieldAccess in the filter condition to
  // reference the Join output.
  //
  // 2. If Filter does not reference correlated variables, simply
  // rewrite the filter condition using new input.
  //

  final RelNode oldInput = rel.getInput();
  Frame frame = getInvoke(oldInput, rel);
  if (frame == null) {
    // If input has not been rewritten, do not rewrite this rel.
    return null;
  }

  // If this Filter has correlated reference, create value generator
  // and produce the correlated variables in the new output.
  if (false) {
    if (cm.mapRefRelToCorRef.containsKey(rel)) {
      frame = decorrelateInputWithValueGenerator(rel, frame);
    }
  } else {
    frame = maybeAddValueGenerator(rel, frame);
  }

  final CorelMap cm2 = new CorelMapBuilder().build(rel);

  // Replace the filter expression to reference output of the join
  // Map filter to the new filter over join
  relBuilder.push(frame.r)
      .filter(decorrelateExpr(currentRel, map, cm2, rel.getCondition()));

  // Filter does not change the input ordering.
  // Filter rel does not permute the input.
  // All corVars produced by filter will have the same output positions in the
  // input rel.
  return register(rel, relBuilder.build(), frame.oldToNewOutputs,
      frame.corDefOutputs);
}