001package gudusoft.gsqlparser.resolver2.iterative; 002 003import gudusoft.gsqlparser.TStatementList; 004import gudusoft.gsqlparser.compiler.TContext; 005import gudusoft.gsqlparser.resolver2.model.ResolutionStatistics; 006 007/** 008 * Strategy for iterative resolution. 009 * 010 * <p>Different strategies can be used for different types of SQL: 011 * - Standard strategy: Normal forward resolution 012 * - Bottom-up strategy: Resolve innermost subqueries first 013 * - Top-down strategy: Resolve outer queries first, push down requirements 014 * - Adaptive strategy: Dynamically choose based on query structure 015 * 016 * <p>Each strategy defines: 017 * - How to order resolution (which tables/CTEs first) 018 * - When to perform inference 019 * - When to expand star columns 020 * - When to push down column requirements 021 */ 022public interface ResolutionStrategy { 023 024 /** 025 * Get the name of this strategy. 026 * 027 * @return strategy name 028 */ 029 String getName(); 030 031 /** 032 * Determine if this strategy should perform inference in the current pass. 033 * 034 * @param passNumber the current pass number 035 * @param previousStats statistics from previous pass (null for first pass) 036 * @return true if inference should be performed 037 */ 038 boolean shouldPerformInference(int passNumber, ResolutionStatistics previousStats); 039 040 /** 041 * Determine if this strategy should expand star columns in the current pass. 042 * 043 * @param passNumber the current pass number 044 * @param previousStats statistics from previous pass (null for first pass) 045 * @return true if star expansion should be performed 046 */ 047 boolean shouldExpandStars(int passNumber, ResolutionStatistics previousStats); 048 049 /** 050 * Determine if this strategy should push down column requirements in the current pass. 051 * 052 * @param passNumber the current pass number 053 * @param previousStats statistics from previous pass (null for first pass) 054 * @return true if push-down should be performed 055 */ 056 boolean shouldPushDownColumns(int passNumber, ResolutionStatistics previousStats); 057 058 /** 059 * Prepare for a new pass. 060 * Strategy can adjust its behavior based on previous results. 061 * 062 * @param passNumber the upcoming pass number 063 * @param previousStats statistics from previous pass (null for first pass) 064 */ 065 void preparePass(int passNumber, ResolutionStatistics previousStats); 066 067 /** 068 * Get a description of this strategy. 069 * 070 * @return strategy description 071 */ 072 String getDescription(); 073}