Skip to main content

Module sql_columns

Module sql_columns 

Source
Expand description

Projection + column read/write extraction.

Builds on the table/alias resolution from (sql_resolve). Given a SqlStatementModel whose tables + alias_scope are populated, this pass fills projection, reads, and writes by walking the SELECT list, the INSERT/UPDATE column targets, and the WHERE/SET/ON predicate columns — attaching a ColumnResolution verdict to each.

Resolution rules:

  • alias.col → look the alias up in AliasScope; if found, Resolved; if the alias isn’t bound, Unresolved.
  • bare col with exactly one table in scope → Resolved against that table.
  • bare col with multiple tables in scope → Unresolved (ambiguous without catalog column lists; the catalog cross-check pass disambiguates later).
  • * / alias.*StarExpansion.

§/oracle evidence

  • DATABASE-REFERENCE.md PL/SQL Language Reference — the SELECT-list / SET-clause / predicate grammar defers to the SQL Language Reference.
  • LOW-LEVEL-CATALOGS.md Data Dictionary View Families — ALL_TAB_COLUMNS is the authority that turns an Unresolved bare column into a Resolved one once the catalog is available (deferred to a later pass).

Functions§

extract_columns
Populate projection, reads, writes on model from its raw text + already-resolved tables / alias_scope. raw is the original SQL text (the model doesn’t keep it).
extract_columns_for_model
Convenience: run extract_columns over every statement in a SqlSemanticModel. The caller supplies the raw text per statement (the model is text-free by design).