java.lang.Object
com.darkcollective.relix.plan.internal.PhysicalPlanJson

public final class PhysicalPlanJson extends Object
Serializes a physical PhysicalNode plan to JSON.

This is the machine-readable counterpart to PhysicalPlanPrinter's ASCII tree: like that printer it surfaces the physical decisions invisible in the logical IR — the SQL pushed to a connection (PhysicalNode.PushedScan) and each join's algorithm and build side — but as structured output for the playground's physical-plan panel.

Node shape

Every node is a JSON object with op (the operator name), its already resolved schema ({open, columns}), estimatedRows (the planner's cardinality estimate, or null when it made none — which is not the same as 0), and children. Nodes that carry a physical decision add fields:
  • Scan — source (the base relation name)
  • PushedScan — connectorType, connection, and the pushed query
  • Join — kind, algorithm, build
  • SetOp — kind
  • Unnest — column, outer, ordinality (if present)
  • Limit — count, offset (or null)
  • Distinct/Aggregate — streaming (single-pass over an ordered input)
The remaining streaming/materialising operators carry no extra fields — their logical detail is available in the logical-plan JSON.

Unlike the logical plan, a physical node's schema is always resolved, so schema is never null; an open (schema-on-read) node renders as {"open": true, "columns": []}.

  • Method Details

    • toJson

      public static String toJson(PhysicalNode root)
      Serializes the plan rooted at root to a standalone JSON string.
      Parameters:
      root - the physical plan root; must not be null
      Returns:
      the JSON document for the plan
    • toJson

      public static String toJson(PhysicalNode root, PlanEstimates estimates)
      Serializes the plan rooted at root to a standalone JSON string, annotating each node with its estimated row count.
      Parameters:
      root - the physical plan root; must not be null
      estimates - the estimates recorded while planning; must not be null
      Returns:
      the JSON document for the plan