Class DynamicStarSource
Object
gudusoft.gsqlparser.resolver2.namespace.AbstractNamespace
gudusoft.gsqlparser.resolver2.namespace.DynamicStarSource
- All Implemented Interfaces:
INamespace
Dynamic namespace for handling SELECT * without metadata.
This namespace represents a table or subquery where we have SELECT * but no schema information. It dynamically infers columns based on: - Usage in WHERE clauses - Usage in JOIN conditions - Usage in other parts of the query
Example scenario:
-- No metadata available for employees table SELECT * FROM employees e WHERE e.department_id = 10 AND e.salary > 50000 DynamicStarSource will infer: - "department_id" column (from WHERE clause) - "salary" column (from WHERE clause)
The inference is done lazily - columns are added as evidence is discovered during resolution. This allows the resolver to handle queries without schema information.
Confidence scoring: - Qualified references (t.col): High confidence (0.95) - JOIN conditions: Very high confidence (0.9) - Unqualified references: Lower confidence (0.5-0.8)
-
Field Summary
Fields inherited from class gudusoft.gsqlparser.resolver2.namespace.AbstractNamespace
columnSources, columnSourcesWithRefs, guessColumnStrategy, nameMatcher, node, referenceTraceabilityEnabled, validated -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddInferredColumn(String columnName, double confidence, String evidence) Add a dynamically inferred column.voidaddInferredColumn(String columnName, ColumnSource columnSource) Add a dynamically inferred column from an existing ColumnSource.protected voidSubclasses override this to perform actual validation logic.Get all column sources exposed by this namespace.Get a display name for this namespace (for debugging/error messages)Get the final physical table this namespace represents.Get the inference engine for this star source.intGet the number of dynamically inferred columns.Get all columns that were inferred (not from SELECT list directly).Get statistics about this dynamic star source.Check if a column exists in this namespace.booleanCheck if any columns have been inferred.booleanCheck if this namespace contains a star column (SELECT *).voidInfer columns from the inference engine's evidence.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, getAllFinalTables, 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
getSelectStatement, getSourceTable, getStarColumn, resolveColumnPath
-
Constructor Details
-
DynamicStarSource
-
-
Method Details
-
getInferenceEngine
Get the inference engine for this star source. External code can add evidence to this engine.- Returns:
- the inference engine
-
addInferredColumn
Add a dynamically inferred column.- Parameters:
columnName- the column nameconfidence- the confidence scoreevidence- the evidence description- Returns:
- true if the column was added, false if it already exists
-
addInferredColumn
Add a dynamically inferred column from an existing ColumnSource. This is used for reverse inference (Principle 3: Star Column双向处理).- Parameters:
columnName- the column namecolumnSource- the column source with confidence and evidence
-
inferColumnsFromEvidence
Infer columns from the inference engine's evidence. This should be called after all evidence has been collected. -
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
-
getAllColumnSources
Description copied from interface:INamespaceGet all column sources exposed by this namespace. Used for SELECT * expansion and smart completion.- Specified by:
getAllColumnSourcesin interfaceINamespace- Overrides:
getAllColumnSourcesin classAbstractNamespace- Returns:
- Map of column name -> ColumnSource
-
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
-
getDisplayName
Description copied from interface:INamespaceGet a display name for this namespace (for debugging/error messages) -
getInferredColumnCount
Get the number of dynamically inferred columns.- Returns:
- column count
-
hasInferredColumns
Check if any columns have been inferred.- Returns:
- true if columns were inferred, false otherwise
-
getStatistics
Get statistics about this dynamic star source.- Returns:
- statistics string
-
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
-
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
-
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
-
toString
- Overrides:
toStringin classAbstractNamespace
-