Record Class SolveNode

java.lang.Object
java.lang.Record
com.darkcollective.relix.ast.SolveNode
Record Components:
left - the left-hand side of the equation; must not be null
right - the right-hand side of the equation; must not be null
input - the relation whose rows are completed; must not be null
location - the source location of this node; never null
All Implemented Interfaces:
RelNode

public record SolveNode(Operand left, Operand right, RelNode input, SourceLocation location) extends Record implements RelNode
Goal-seek (SOLVE) — a per-row operator that fills a single unknown column by inverting a declared arithmetic equation left = right.

For each input row, the participating columns are the distinct attribute references appearing anywhere in left or right. Whichever single participating column is NULL in that row is the unknown: solve rearranges the equation to compute it and emits the completed row. The direction is therefore per-row — the same equation fills principal in one row and rate in another, depending on which is blank.

Rows that do not have exactly one NULL participating column pass through unchanged: a fully-populated row is already complete (no recompute or validation), and a row with two or more blanks is underdetermined (its NULLs are left intact).

The output schema equals the input schema — solve fills holes, it never adds or removes columns. Both sides are restricted to invertible arithmetic (column references, numeric literals, + − × ÷ and unary minus), and each participating column may appear at most once across the whole equation, so the inversion is deterministic regardless of which column is the runtime unknown. This operator runs in-engine and never pushes down.

Example: SOLVE total = principal * rate (Loans) fills whichever of total, principal, or rate is blank in each loan row.

  • Constructor Details

    • SolveNode

      public SolveNode(Operand left, Operand right, RelNode input, SourceLocation location)
      Creates an instance of a SolveNode record class.
      Parameters:
      left - the value for the left record component
      right - the value for the right record component
      input - the value for the input record component
      location - the value for the location record component
    • SolveNode

      public SolveNode(Operand left, Operand right, RelNode input)
      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. All components in this record class are compared with Objects::equals(Object,Object).
      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 Operand left()
      Returns the value of the left record component.
      Returns:
      the value of the left record component
    • right

      public Operand right()
      Returns the value of the right record component.
      Returns:
      the value of the right record component
    • input

      public RelNode input()
      Returns the value of the input record component.
      Returns:
      the value of the input 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