java.lang.Object
com.darkcollective.relix.semantic.internal.SchemaInference

public final class SchemaInference extends Object
Public facade for running schema inference over an arbitrary RelNode tree outside the full five-phase analysis pipeline.

This is primarily intended for consumers — such as the query optimizer and execution engine — that hold a tree which is not the one originally analysed (for example, a tree rewritten by optimization passes) and therefore has no entries in the original SemanticModel.nodeSchemas() map. Because SchemaAnnotations is keyed by object identity, a rewritten tree's nodes are unknown to the original annotation map and must be re-annotated before they can be executed.

Merging semantics

annotate(com.darkcollective.relix.symbol.table.SymbolTable, com.darkcollective.relix.ast.RelNode, com.darkcollective.relix.semantic.SchemaAnnotations, com.darkcollective.relix.function.FunctionCatalog) returns a fresh SchemaAnnotations seeded from the supplied base map and then augmented with annotations for root and all of its descendants. Existing entries are preserved: this matters when root contains RelationNode leaves that reference named views ( QueryRelationSymbols) whose own bodies were annotated during the original analysis but are not re-walked here.

Thread safety

Stateless; safe to call concurrently. Each call builds its own annotation map and visitor.

  • Method Details

    • annotate

      public static SchemaAnnotations annotate(SymbolTable symbolTable, RelNode root, SchemaAnnotations base, FunctionCatalog functions)
      Returns a SchemaAnnotations containing every entry from base plus a freshly-inferred schema for root and each of its descendant nodes.

      The base map is not mutated. Inference errors are not surfaced: callers are expected to supply a tree derived from an already-valid model (e.g. an optimizer rewrite, which is semantics-preserving), so any node that cannot be resolved simply remains unannotated.

      Parameters:
      symbolTable - the symbol table used to resolve relation and function references; must not be null
      root - the root of the tree to annotate; must not be null
      base - annotations to seed the result with (typically the original SemanticModel.nodeSchemas()); must not be null
      functions - the catalogue function calls in the tree are typed against — pass the one the tree was analysed with (SemanticModel.functions()), so a re-annotated tree types its calls exactly as the original did; must not be null
      Returns:
      a new annotation map covering base and root's subtree