java.lang.Object
com.darkcollective.relix.semantic.internal.SchemaInferenceVisitor
All Implemented Interfaces:
RelNodeVisitor<Optional<Schema>>

public final class SchemaInferenceVisitor extends Object implements RelNodeVisitor<Optional<Schema>>
Infers the output Schema of every node in a relational algebra tree.

Each visit method returns the inferred schema for that node as an Optional<Schema>. An empty optional signals that inference failed for the subtree (e.g. an unresolved relation name); the failure is recorded in the errors list and the node is left unannotated.

Successfully inferred schemas are written into the SchemaAnnotations map supplied at construction time, keyed by object identity so that separate occurrences of the same node structure are tracked independently.

Schema rules per operation

RelationNode
schema from the symbol table
SelectionNode, SortNode, LimitNode, DistinctNode
passthrough of input schema
ProjectionNode
one column per projected attribute; name from alias or attribute name; type inferred from operand kind and input schema
RenameNode
if attribute list is non-empty, rename columns positionally; otherwise same schema as input
NaturalJoinNode
left columns, then right columns whose names do not appear in left
ThetaJoinNode, LeftOuterJoinNode, RightOuterJoinNode, FullOuterJoinNode, ProductNode
concatenation of left and right schemas; right-side duplicate column names are suffixed with _r (and _r1, _r2, …) to keep names unique
SemiJoinNode, AntiJoinNode
left schema only
UnionNode, UnionAllNode, IntersectionNode, DifferenceNode
left schema (compatible with right by convention)
DivisionNode
left columns whose names do not appear in the right schema
AggregationNode
group-by columns (from input schema) followed by one column per aggregate function (alias or operator_attribute name)