Class UnionNamespace
Object
gudusoft.gsqlparser.resolver2.namespace.AbstractNamespace
gudusoft.gsqlparser.resolver2.namespace.UnionNamespace
- All Implemented Interfaces:
INamespace
Namespace representing a UNION/INTERSECT/EXCEPT query.
Key characteristics:
- Schema is defined by the FIRST branch (SQL standard)
- Columns must be pushed down to ALL branches
- hasStarColumn() returns true if ANY branch has SELECT *
- addInferredColumn() propagates to ALL branches
Example:
FROM (
SELECT * FROM table_1
UNION ALL
SELECT * FROM table_2
UNION ALL
SELECT * FROM table_3
) Combined
When outer query references "col_1", it should be pushed to ALL branches.
-
Field Summary
Fields inherited from class gudusoft.gsqlparser.resolver2.namespace.AbstractNamespace
columnSources, columnSourcesWithRefs, guessColumnStrategy, nameMatcher, node, referenceTraceabilityEnabled, validated -
Constructor Summary
ConstructorsConstructorDescriptionUnionNamespace(TSelectSqlStatement unionQuery, String alias, INameMatcher nameMatcher) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddInferredColumn(String columnName, double confidence, String evidence) Add an inferred column to this namespace.protected voidSubclasses override this to perform actual validation logic.Get all branch SELECT statements.Get all final physical tables this namespace depends on.intGet the number of UNION branches.Get all branch namespaces.Get a display name for this namespace (for debugging/error messages)Get the final physical table this namespace represents.Get all columns that were inferred (not from SELECT list directly).Get the underlying SELECT statement for this namespace.Check if a column exists in this namespace.booleanCheck if this namespace contains a star column (SELECT *).resolveColumn(String columnName) Resolve a column name to its source.booleanCheck if this namespace supports dynamic column inference.toString()Methods inherited from class gudusoft.gsqlparser.resolver2.namespace.AbstractNamespace
addColumnSource, addColumnSource, enableReferenceTraceability, ensureValidated, getAllColumnSources, getAllUniqueColumns, getColumnReferences, getColumnSourceWithReferences, getGuessColumnStrategy, getNameMatcher, getNode, isReferenceTraceabilityEnabled, isValidated, setGuessColumnStrategy, validateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface gudusoft.gsqlparser.resolver2.namespace.INamespace
getSourceTable, getStarColumn, resolveColumnPath
-
Constructor Details
-
UnionNamespace
-
-
Method Details
-
getDisplayName
Description copied from interface:INamespaceGet a display name for this namespace (for debugging/error messages) -
getFinalTable
Description copied from interface:INamespaceGet the final physical table this namespace represents. For tables: returns the table itself For subqueries/CTEs: recursively traces back to physical table(s)- Returns:
- Physical table, or null if not determinable
-
getAllFinalTables
Description copied from interface:INamespaceGet all final physical tables this namespace depends on. For simple table namespace: returns single table For subquery/CTE: returns all tables in the query tree- Specified by:
getAllFinalTablesin interfaceINamespace- Overrides:
getAllFinalTablesin classAbstractNamespace- Returns:
- List of all physical tables
-
doValidate
Description copied from class:AbstractNamespaceSubclasses override this to perform actual validation logic.- Specified by:
doValidatein classAbstractNamespace
-
hasColumn
Description copied from interface:INamespaceCheck if a column exists in this namespace. Returns a three-level answer: EXISTS, MAYBE, NOT_EXISTS- Specified by:
hasColumnin interfaceINamespace- Overrides:
hasColumnin classAbstractNamespace- Parameters:
columnName- Column name to check- Returns:
- Column existence level
-
resolveColumn
Description copied from interface:INamespaceResolve a column name to its source.- Specified by:
resolveColumnin interfaceINamespace- Overrides:
resolveColumnin classAbstractNamespace- Parameters:
columnName- Column name to resolve- Returns:
- ColumnSource if found, null otherwise
-
getSelectStatement
Description copied from interface:INamespaceGet the underlying SELECT statement for this namespace. For CTENamespace: returns the CTE's subquery For SubqueryNamespace: returns the subquery For TableNamespace: returns null- Returns:
- the SELECT statement, or null if not applicable
-
hasStarColumn
Description copied from interface:INamespaceCheck if this namespace contains a star column (SELECT *). Used to identify namespaces that may need star column inference.- Returns:
- true if the namespace has SELECT *, false otherwise
-
supportsDynamicInference
Description copied from interface:INamespaceCheck if this namespace supports dynamic column inference. DynamicStarSource and similar namespaces return true.- Returns:
- true if this namespace can have columns added dynamically
-
addInferredColumn
Description copied from interface:INamespaceAdd an inferred column to this namespace. Used by star column push-down to add columns discovered from outer queries.- Parameters:
columnName- the column name to addconfidence- the confidence score (0.0 to 1.0)evidence- description of why this column was inferred- Returns:
- true if the column was added, false if already exists
-
getInferredColumns
Description copied from interface:INamespaceGet all columns that were inferred (not from SELECT list directly). These are columns discovered through star column push-down.- Returns:
- set of inferred column names, empty if none
-
getBranchNamespaces
Get all branch namespaces. Useful for external code that needs to iterate over branches. -
getAllBranches
Get all branch SELECT statements. -
getBranchCount
Get the number of UNION branches. -
toString
- Overrides:
toStringin classAbstractNamespace
-