Class TSQLResolver2

Object
gudusoft.gsqlparser.resolver2.TSQLResolver2

public class TSQLResolver2 extends Object
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 Details

  • Method Details

    • setSqlEnv

      public void setSqlEnv(TSQLEnv sqlEnv)
      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

      public TSQLEnv 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

      public static void 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

      public boolean 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

      public static 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