Record Class AsOfJoinNode

java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.AsOfJoinNode
Record Components:
left - the left (probe) relation; must not be null
right - the right (lookup) relation; must not be null
condition - the match condition (equality keys + one ordering inequality); must not be null
tolerance - optional WITHIN clause — a DURATION bound on the match distance
inner - when true, unmatched probes are dropped (inner variant); when false (default), they are emitted with NULL right columns
tieBreak - how to break ties among right rows at the same nearest-match value
location - the source location of this node; never null
All Implemented Interfaces:
RelNode

public record AsOfJoinNode(RelNode left, RelNode right, Predicate condition, Optional<Operand> tolerance, boolean inner, TieBreak tieBreak, SourceLocation location) extends Record implements RelNode
AS-OF join (ASOF) — a temporal "pick the nearest right row by time" join.

For each left (probe) row, among the right rows that agree on the equality conjuncts of condition (the partition keys) and satisfy its single ordering inequality (the match column), the join emits the probe concatenated with the single nearest such right row. The inequality operator fixes the direction:

  • ℓ.ts >= r.ts / ℓ.ts > r.ts — backward: the greatest r.ts at-or-before (or strictly before) the probe.
  • ℓ.ts <= r.ts / ℓ.ts < r.ts — forward: the least r.ts at-or-after (or strictly after) the probe.

By default the join is left-outer: every probe survives, with the right columns NULL when no right row matches. Setting inner to true switches to the inner variant, which drops unmatched probes.

An optional tolerance (a WITHIN durExpr clause) imposes a maximum temporal distance between the probe and the matched right row; a candidate whose distance exceeds the tolerance is treated as no-match.

The tieBreak rule resolves ties when multiple right rows share the nearest match value: TieBreak.LAST (default) keeps the last such row in input order; TieBreak.FIRST keeps the first.

  • Constructor Details

    • AsOfJoinNode

      public AsOfJoinNode(RelNode left, RelNode right, Predicate condition, Optional<Operand> tolerance, boolean inner, TieBreak tieBreak, SourceLocation location)
      Creates an instance of a AsOfJoinNode record class.
      Parameters:
      left - the value for the left record component
      right - the value for the right record component
      condition - the value for the condition record component
      tolerance - the value for the tolerance record component
      inner - the value for the inner record component
      tieBreak - the value for the tieBreak record component
      location - the value for the location record component
    • AsOfJoinNode

      public AsOfJoinNode(RelNode left, RelNode right, Predicate condition, SourceLocation location)
      Convenience constructor with no tolerance, left-outer behaviour, and last-wins tie-break; uses the given source location.
    • AsOfJoinNode

      public AsOfJoinNode(RelNode left, RelNode right, Predicate condition)
      Convenience constructor for tests; uses SourceLocation.UNKNOWN.
  • Method Details

    • accept

      public <R> R accept(RelNodeVisitor<R> visitor)
      Specified by:
      accept in interface RelNode
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • left

      public RelNode left()
      Returns the value of the left record component.
      Returns:
      the value of the left record component
    • right

      public RelNode right()
      Returns the value of the right record component.
      Returns:
      the value of the right record component
    • condition

      public Predicate condition()
      Returns the value of the condition record component.
      Returns:
      the value of the condition record component
    • tolerance

      public Optional<Operand> tolerance()
      Returns the value of the tolerance record component.
      Returns:
      the value of the tolerance record component
    • inner

      public boolean inner()
      Returns the value of the inner record component.
      Returns:
      the value of the inner record component
    • tieBreak

      public TieBreak tieBreak()
      Returns the value of the tieBreak record component.
      Returns:
      the value of the tieBreak record component
    • location

      public SourceLocation location()
      Returns the value of the location record component.
      Specified by:
      location in interface RelNode
      Returns:
      the value of the location record component