Package gudusoft.gsqlparser.resolver2
Class TSQLResolver2
Object
gudusoft.gsqlparser.resolver2.TSQLResolver2
New SQL Resolver - Phase 2 Enhanced Framework
This is the main entry point for the new resolution architecture.
Provides improved column-to-table resolution with:
- Clear scope-based name resolution
- Full candidate collection for ambiguous cases
- Confidence-scored inference
- Better tracing and debugging
Usage:
TSQLResolver2 resolver = new TSQLResolver2(context, statements); boolean success = resolver.resolve(); ResolutionStatistics stats = resolver.getStatistics();Phase 1 capabilities: - Basic SELECT statement resolution - Table and subquery namespaces - Qualified and unqualified column references - FROM clause scope management Phase 2 capabilities: - JOIN scope handling with nullable semantics - CTE (WITH clause) resolution - Iterative resolution framework (auto-converges after first pass if no iteration needed) Future phases will add: - Evidence-based inference - Star column expansion
-
Constructor Summary
ConstructorsConstructorDescriptionTSQLResolver2(gudusoft.gsqlparser.compiler.TContext context, TStatementList statements) Create resolver with default configurationTSQLResolver2(gudusoft.gsqlparser.compiler.TContext context, TStatementList statements, TSQLResolverConfig config) Create resolver with custom configuration -
Method Summary
Modifier and TypeMethodDescriptionGet the configurationGet the resolution context (for advanced queries)Get the convergence detector (for iterative resolution analysis)Get a detailed enhancement report.static StringGet global performance timing breakdown for profiling across all resolve() calls.Get the global scopestatic StringGet detailed legacy sync timing breakdown.Get the namespace enhancer for external access to enhancement history.Get the pass history (for iterative resolution analysis)Get performance timing breakdown for profiling.Get the resolution result access interface.Get the scope build result (for testing and analysis)Get the TSQLEnv used for table metadata lookup.Get the SQL statements being resolved.Get resolution statisticsGet the set of virtual trigger tables (deleted/inserted in SQL Server triggers).static voidReset global timing accumulators.booleanresolve()Perform resolution on all SQL statementsvoidSet the TSQLEnv to use for table metadata lookup.
-
Constructor Details
-
TSQLResolver2
Create resolver with default configuration -
TSQLResolver2
public TSQLResolver2(gudusoft.gsqlparser.compiler.TContext context, TStatementList statements, TSQLResolverConfig config) Create resolver with custom configuration
-
-
Method Details
-
setSqlEnv
Set the TSQLEnv to use for table metadata lookup. This allows external callers to provide TSQLEnv if automatic detection fails.- Parameters:
sqlEnv- the SQL environment containing table metadata
-
getSqlEnv
Get the TSQLEnv used for table metadata lookup.- Returns:
- the SQL environment, or null if not set
-
getVirtualTriggerTables
Get the set of virtual trigger tables (deleted/inserted in SQL Server triggers). These tables should be excluded from table output since their columns are resolved to the trigger's target table.- Returns:
- Set of TTable objects that are virtual trigger tables
-
getStatements
Get the SQL statements being resolved.- Returns:
- the list of SQL statements
-
resetGlobalTimings
Reset global timing accumulators. -
getGlobalPerformanceTimings
Get global performance timing breakdown for profiling across all resolve() calls.- Returns:
- formatted timing information
-
getPerformanceTimings
Get performance timing breakdown for profiling.- Returns:
- formatted timing information
-
resolve
Perform resolution on all SQL statements -
getNamespaceEnhancer
Get the namespace enhancer for external access to enhancement history.- Returns:
- the namespace enhancer
-
getEnhancementReport
Get a detailed enhancement report.- Returns:
- detailed report string
-
getLegacySyncTimings
Get detailed legacy sync timing breakdown. -
getStatistics
Get resolution statistics -
getContext
Get the resolution context (for advanced queries) -
getGlobalScope
Get the global scope -
getConfig
Get the configuration -
getPassHistory
Get the pass history (for iterative resolution analysis)- Returns:
- list of all resolution passes (empty if non-iterative or not yet resolved)
-
getConvergenceDetector
Get the convergence detector (for iterative resolution analysis)- Returns:
- convergence detector (null if iterative resolution is disabled)
-
getScopeBuildResult
Get the scope build result (for testing and analysis)- Returns:
- scope build result from ScopeBuilder (null if not yet resolved)
-
getResult
Get the resolution result access interface. This provides a clean, statement-centric API for accessing resolution results.Usage example:
TSQLResolver2 resolver = new TSQLResolver2(null, parser.sqlstatements); resolver.resolve(); IResolutionResult result = resolver.getResult(); for (TCustomSqlStatement stmt : parser.sqlstatements) { for (TTable table : result.getTables(stmt)) { System.out.println("Table: " + table.getFullName()); for (TObjectName col : result.getColumnsForTable(stmt, table)) { System.out.println(" Column: " + col.getColumnNameOnly()); } } }- Returns:
- resolution result access interface
- Throws:
IllegalStateException- if resolve() has not been called
-