Class SchemaInference
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 Summary
Modifier and TypeMethodDescriptionstatic SchemaAnnotationsannotate(SymbolTable symbolTable, RelNode root, SchemaAnnotations base, FunctionCatalog functions) Returns aSchemaAnnotationscontaining every entry frombaseplus a freshly-inferred schema forrootand each of its descendant nodes.
-
Method Details
-
annotate
public static SchemaAnnotations annotate(SymbolTable symbolTable, RelNode root, SchemaAnnotations base, FunctionCatalog functions) Returns aSchemaAnnotationscontaining every entry frombaseplus a freshly-inferred schema forrootand 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 benullroot- the root of the tree to annotate; must not benullbase- annotations to seed the result with (typically the originalSemanticModel.nodeSchemas()); must not benullfunctions- 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 benull- Returns:
- a new annotation map covering
baseandroot's subtree
-