001package gudusoft.gsqlparser.common.structured;
002
003import gudusoft.gsqlparser.nodes.TObjectName;
004
005/**
006 * Describes the source column from which a structured value is derived.
007 * For the Spark {@code from_json(nodes, schema)} adapter, the source is
008 * the {@code nodes} column reference.
009 */
010public final class StructuredValueSource {
011
012    private final TObjectName sourceColumn;
013    private final String sourceAlias;
014    private final String rootColumnName;
015
016    public StructuredValueSource(TObjectName sourceColumn,
017                                 String sourceAlias,
018                                 String rootColumnName) {
019        if (rootColumnName == null || rootColumnName.isEmpty()) {
020            throw new IllegalArgumentException("rootColumnName must be non-empty");
021        }
022        this.sourceColumn = sourceColumn;
023        this.sourceAlias = sourceAlias;
024        this.rootColumnName = rootColumnName;
025    }
026
027    public TObjectName getSourceColumn() {
028        return sourceColumn;
029    }
030
031    /** Optional relation alias used in the SQL, e.g. "src" in {@code src.nodes}. */
032    public String getSourceAlias() {
033        return sourceAlias;
034    }
035
036    public String getRootColumnName() {
037        return rootColumnName;
038    }
039}