Class Filter

All Implemented Interfaces:
Cloneable, RelOptNode, Hintable, RelNode
Direct Known Subclasses:
Bindables.BindableFilter, CassandraFilter, ElasticsearchFilter, EnumerableFilter, GeodeFilter, InnodbFilter, JdbcRules.JdbcFilter, LogicalFilter, MongoFilter, PigFilter

public abstract class Filter extends SingleRel implements Hintable
Relational expression that iterates over its input and returns elements for which condition evaluates to true.

If the condition allows nulls, then a null value is treated the same as false.

See Also:
  • Field Details

    • condition

      protected final RexNode condition
    • hints

      protected final com.google.common.collect.ImmutableList<RelHint> hints
  • Constructor Details

    • Filter

      protected Filter(RelOptCluster cluster, RelTraitSet traits, List<RelHint> hints, RelNode child, RexNode condition)
      Creates a filter.
      Parameters:
      cluster - Cluster that this relational expression belongs to
      traits - the traits of this rel
      hints - Hints for this node
      child - input relational expression
      condition - boolean expression which determines whether a row is allowed to pass
    • Filter

      protected Filter(RelOptCluster cluster, RelTraitSet traits, RelNode child, RexNode condition)
      Creates a filter.
      Parameters:
      cluster - Cluster that this relational expression belongs to
      traits - the traits of this rel
      child - input relational expression
      condition - boolean expression which determines whether a row is allowed to pass
    • Filter

      protected Filter(RelInput input)
      Creates a Filter by parsing serialized output.
  • Method Details

    • copy

      public final RelNode copy(RelTraitSet traitSet, List<RelNode> inputs)
      Description copied from interface: RelNode
      Creates a copy of this relational expression, perhaps changing traits and inputs.

      Sub-classes with other important attributes are encouraged to create variants of this method with more parameters.

      Specified by:
      copy in interface RelNode
      Overrides:
      copy in class AbstractRelNode
      Parameters:
      traitSet - Trait set
      inputs - Inputs
      Returns:
      Copy of this relational expression, substituting traits and inputs
    • copy

      public abstract Filter copy(RelTraitSet traitSet, RelNode input, RexNode condition)
    • accept

      public RelNode accept(RexShuttle shuttle)
      Description copied from interface: RelNode
      Accepts a visit from a shuttle. If the shuttle updates expression, then a copy of the relation should be created. This new relation might have a different row-type.
      Specified by:
      accept in interface RelNode
      Overrides:
      accept in class AbstractRelNode
      Parameters:
      shuttle - Shuttle
      Returns:
      A copy of this node incorporating changes made by the shuttle to this node's children
    • getCondition

      public RexNode getCondition()
    • containsOver

      public final boolean containsOver()
      Returns whether this Filter contains any windowed-aggregate functions.
    • isValid

      public boolean isValid(Litmus litmus, @Nullable RelNode.Context context)
      Description copied from interface: RelNode
      Returns whether this relational expression is valid.

      If assertions are enabled, this method is typically called with litmus = THROW, as follows:

      assert rel.isValid(Litmus.THROW)

      This signals that the method can throw an AssertionError if it is not valid.

      Specified by:
      isValid in interface RelNode
      Overrides:
      isValid in class AbstractRelNode
      Parameters:
      litmus - What to do if invalid
      context - Context for validity checking
      Returns:
      Whether relational expression is valid
    • computeSelfCost

      public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq)
      Description copied from interface: RelNode
      Returns the cost of this plan (not including children). The base implementation throws an error; derived classes should override.

      NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getNonCumulativeCost(org.apache.calcite.rel.RelNode), which gives plugins a chance to override the rel's default ideas about cost.

      Specified by:
      computeSelfCost in interface RelNode
      Overrides:
      computeSelfCost in class AbstractRelNode
      Parameters:
      planner - Planner for cost calculation
      mq - Metadata query
      Returns:
      Cost of this plan (not including children)
    • estimateRowCount

      public double estimateRowCount(RelMetadataQuery mq)
      Description copied from interface: RelNode
      Returns an estimate of the number of rows this relational expression will return.

      NOTE jvs 29-Mar-2006: Don't call this method directly. Instead, use RelMetadataQuery.getRowCount(org.apache.calcite.rel.RelNode), which gives plugins a chance to override the rel's default ideas about row count.

      Specified by:
      estimateRowCount in interface RelNode
      Overrides:
      estimateRowCount in class SingleRel
      Parameters:
      mq - Metadata query
      Returns:
      Estimate of the number of rows this relational expression will return
    • estimateFilteredRows

      @Deprecated public static double estimateFilteredRows(RelNode child, RexProgram program)
      Deprecated.
    • estimateFilteredRows

      @Deprecated public static double estimateFilteredRows(RelNode child, RexNode condition)
      Deprecated.
    • explainTerms

      public RelWriter explainTerms(RelWriter pw)
      Description copied from class: AbstractRelNode
      Describes the inputs and attributes of this relational expression. Each node should call super.explainTerms, then call the RelWriter.input(String, RelNode) and RelWriter.item(String, Object) methods for each input and attribute.
      Overrides:
      explainTerms in class SingleRel
      Parameters:
      pw - Plan writer
      Returns:
      Plan writer for fluent-explain pattern
    • deepEquals0

      @API(since="1.24", status=INTERNAL) @EnsuresNonNullIf(expression="#1", result=true) protected boolean deepEquals0(@Nullable Object obj)
    • deepHashCode0

      @API(since="1.24", status=INTERNAL) protected int deepHashCode0()
    • getHints

      public com.google.common.collect.ImmutableList<RelHint> getHints()
      Description copied from interface: Hintable
      Returns the hints of this relational expressions as an immutable list.
      Specified by:
      getHints in interface Hintable