001package gudusoft.gsqlparser.ir.semantic;
002
003/**
004 * Classification of a relation source in {@link RelationSource}.
005 *
006 * <p>Slice 1 only emits {@link #TABLE}. CTE / SUBQUERY / UNION are
007 * reserved for later slices and exist here so the JSON shape does not
008 * change when those cases land.
009 *
010 * <p>Slice 14 added {@link #OUTER_REFERENCE}: a synthesised relation
011 * an inner statement carries to model an alias actually owned by an
012 * enclosing scope. Slice 15 extends OUTER_REFERENCE so the binding's
013 * {@code outerKind} (set via the 3-arg
014 * {@link gudusoft.gsqlparser.ir.semantic.binding.RelationBinding}
015 * constructor) records what the outer relation is really bound to:
016 * one of {@code {TABLE, CTE, SUBQUERY}}. Canonical-edge emission
017 * dispatches through that resolved kind so CTE / SUBQUERY outer
018 * correlations BFS the outer body to base columns just like
019 * non-correlated CTE / SUBQUERY relations do.
020 */
021public enum RelationKind {
022    TABLE,
023    CTE,
024    SUBQUERY,
025    /**
026     * A table-valued function source, e.g. SQL Server
027     * {@code CROSS APPLY dbo.fn_items(o.id) t} or {@code FROM dbo.fn(1) t}.
028     * Its column set is opaque (no catalog, no sub-statement); referenced
029     * columns ({@code t.q}) resolve to this relation and lineage
030     * terminates at the function's qualified name. The qualifiedName is
031     * the function name; the source alias is carried by
032     * {@code RelationSource.alias}.
033     */
034    FUNCTION,
035    UNION,
036    UNKNOWN,
037    OUTER_REFERENCE
038}