Interface RelWriter

All Known Implementing Classes:
RelDotWriter, RelJsonWriter, RelWriterImpl, RelXmlWriter

public interface RelWriter
Callback for an expression to dump itself to.

It is used for generating EXPLAIN PLAN output, and also for serializing a tree of relational expressions to JSON.

  • Method Summary

    Modifier and Type Method Description
    RelWriter done​(RelNode node)
    Writes the completed explanation.
    void explain​(RelNode rel, List<Pair<String,​Object>> valueList)
    Prints an explanation of a node, with a list of (term, value) pairs.
    SqlExplainLevel getDetailLevel()
    Returns detail level at which plan should be generated.
    default RelWriter input​(String term, RelNode input)
    Adds an input to the explanation of the current node.
    RelWriter item​(String term, Object value)
    Adds an attribute to the explanation of the current node.
    default RelWriter itemIf​(String term, Object value, boolean condition)
    Adds an input to the explanation of the current node, if a condition holds.
    default boolean nest()
    Returns whether the writer prefers nested values.
  • Method Details

    • explain

      void explain​(RelNode rel, List<Pair<String,​Object>> valueList)
      Prints an explanation of a node, with a list of (term, value) pairs.

      The term-value pairs are generally gathered by calling RelNode.explain(RelWriter). Each sub-class of RelNode calls input(String, org.apache.calcite.rel.RelNode) and item(String, Object) to declare term-value pairs.

      Parameters:
      rel - Relational expression
      valueList - List of term-value pairs
    • getDetailLevel

      SqlExplainLevel getDetailLevel()
      Returns detail level at which plan should be generated.
    • input

      default RelWriter input​(String term, RelNode input)
      Adds an input to the explanation of the current node.
      Parameters:
      term - Term for input, e.g. "left" or "input #1".
      input - Input relational expression
    • item

      RelWriter item​(String term, Object value)
      Adds an attribute to the explanation of the current node.
      Parameters:
      term - Term for attribute, e.g. "joinType"
      value - Attribute value
    • itemIf

      default RelWriter itemIf​(String term, Object value, boolean condition)
      Adds an input to the explanation of the current node, if a condition holds.
    • done

      RelWriter done​(RelNode node)
      Writes the completed explanation.
    • nest

      default boolean nest()
      Returns whether the writer prefers nested values. Traditional explain writers prefer flattened values.