Class AsofJoinOperator

java.lang.Object
dev.frostlake.executor.operators.AsofJoinOperator
All Implemented Interfaces:
Operator

public class AsofJoinOperator extends Object implements Operator
Snowflake ASOF JOIN: for every left row, the single CLOSEST right row that satisfies the MATCH_CONDITION — the newest right row at or before the left row's timestamp, and the mirror-image for the < / <= directions.

Live-verified semantics (probed against a real account):

  • The result is LEFT OUTER: a left row with no qualifying right row survives, null-extended over the right table's columns.
  • >= / > pick the right row with the GREATEST match value among those satisfying the condition; <= / < pick the SMALLEST. Those four are the only operators Snowflake allows in a MATCH_CONDITION.
  • A NULL on either side of the comparison never matches, so such right rows are skipped.
  • The optional ON / USING equality clause narrows the candidate set per left row (it partitions the join); without it every right row is a candidate.
  • Constructor Details

    • AsofJoinOperator

      public AsofJoinOperator(Table leftTable, Table rightTable, List<Row> rightRows, BinaryOperator matchOperator, Expression leftMatchExpression, RowExpressionEvaluator leftMatchEvaluator, Expression rightMatchExpression, RowExpressionEvaluator rightMatchEvaluator, JoinConditionEvaluator partitionEvaluator)
      Parameters:
      leftTable - left input metadata
      rightTable - right input metadata
      rightRows - the right input's rows
      matchOperator - the MATCH_CONDITION comparison (>=, >, <=, <)
      leftMatchExpression - the condition's left operand, evaluated against a LEFT row
      leftMatchEvaluator - evaluator bound to the left input
      rightMatchExpression - the condition's right operand, evaluated against a RIGHT row
      rightMatchEvaluator - evaluator bound to the right input
      partitionEvaluator - the ON / USING equality test over a (left, right) pair, or null when absent
  • Method Details

    • execute

      public List<Row> execute(List<Row> leftRows, OperatorContext context)
      Description copied from interface: Operator
      Execute this operator on the input rows.
      Specified by:
      execute in interface Operator
      Parameters:
      leftRows - The input rows from the previous operator
      context - The execution context containing table metadata and other information
      Returns:
      The output rows after applying this operator
    • getDescription

      public String getDescription()
      Description copied from interface: Operator
      Get a description of this operator for debugging/logging.
      Specified by:
      getDescription in interface Operator
      Returns:
      A human-readable description of the operator