Class ResidualEvaluator

java.lang.Object
org.apache.iceberg.expressions.ResidualEvaluator
All Implemented Interfaces:
Serializable

public class ResidualEvaluator extends Object implements Serializable
Finds the residuals for an Expression the partitions in the given PartitionSpec.

A residual expression is made by partially evaluating an expression using partition values. For example, if a table is partitioned by day(utc_timestamp) and is read with a filter expression utc_timestamp >= a and utc_timestamp <= b, then there are 4 possible residuals expressions for the partition data, d:

  • If d > day(a) and d < day(b), the residual is always true
  • If d == day(a) and d != day(b), the residual is utc_timestamp >= a
  • if d == day(b) and d != day(a), the residual is utc_timestamp <= b
  • If d == day(a) == day(b), the residual is utc_timestamp >= a and utc_timestamp <= b

Partition data is passed using StructLike. Residuals are returned by residualFor(StructLike).

This class is thread-safe.

See Also:
  • Method Details

    • unpartitioned

      public static ResidualEvaluator unpartitioned(Expression expr)
      Return a residual evaluator for an unpartitioned spec.
      Parameters:
      expr - an expression
      Returns:
      a residual evaluator that always returns the expression
    • of

      public static ResidualEvaluator of(PartitionSpec spec, Expression expr, boolean caseSensitive)
      Return a residual evaluator for a spec and expression.
      Parameters:
      spec - a partition spec
      expr - an expression
      Returns:
      a residual evaluator for the expression
    • residualFor

      public Expression residualFor(StructLike partitionData)
      Returns a residual expression for the given partition values.
      Parameters:
      partitionData - partition data values
      Returns:
      the residual of this evaluator's expression from the partition values