Class: Upkeep::SQLDependencyAnalysis::Analyzer
- Inherits:
-
Object
- Object
- Upkeep::SQLDependencyAnalysis::Analyzer
- Defined in:
- lib/upkeep/sql_dependency_analysis.rb
Instance Method Summary collapse
- #analyze ⇒ Object
-
#initialize(statement, schema:, scope:) ⇒ Analyzer
constructor
A new instance of Analyzer.
Constructor Details
#initialize(statement, schema:, scope:) ⇒ Analyzer
Returns a new instance of Analyzer.
35 36 37 38 39 40 41 42 43 |
# File 'lib/upkeep/sql_dependency_analysis.rb', line 35 def initialize(statement, schema:, scope:) @statement = statement @scope = scope @columns_by_table = normalize_schema(schema) @table_columns = Hash.new { |hash, table| hash[table] = Set.new } @predicates = [] @equality_edges = Set.new @warnings = [] end |
Instance Method Details
#analyze ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/upkeep/sql_dependency_analysis.rb', line 45 def analyze root = @statement["Select"] set_operation = @statement["SetOperation"] if root process_select(root, outer_sources: {}, visible_ctes: {}) elsif set_operation process_set_operation( set_operation, outer_sources: {}, visible_ctes: {} ) else raise UnsupportedError, "expected a SELECT or set-operation statement" end validate_scope! Result.new( table_columns: normalized_table_columns, predicates: normalized_predicates, equality_edges: @equality_edges.to_a.sort, limit_value: literal_value((root || set_operation)["limit"]), appendable: root ? appendable?(root) : false, warnings: @warnings.uniq.sort ) end |