altimate-code icon indicating copy to clipboard operation
altimate-code copied to clipboard

[BUG]: column answer throws "has no column" for a cast after a SELECT modifier or in parentheses

Open ralphstodomingo opened this issue 2 weeks ago • 1 comments

Description

On Postgres and Redshift, impact_analysis's column answer and column_reach throw "r has no column amount" for a column the model really has, when its cast follows a SELECT modifier or sits in parentheses. The same happens on v0.12.11, so this predates #1754. The review of #1754 found it. Nothing is reported unaffected; the call fails instead of answering.

  • No space after the modifier: select distinct on(id)amount::numeric, id and Redshift's select top 5amount::numeric, id.
  • distinct on with nested parentheses: select distinct on (coalesce(id, 0)) id, amount::numeric.
  • A parenthesised operand: select distinct(amount)::numeric, id, all(amount)::numeric, (amount)::numeric, cast((amount) as numeric).
  • Mixed or nested cast chains keep the engine's _col_1 label, so the trace stops there: cast(amount as numeric)::int, cast(cast(amount as numeric) as int).

Plugins

None needed; the CLI (altimate tool run impact_analysis, column_reach and dbt_lineage).

OpenCode version

main after #1754 (also v0.12.11).

Steps to reproduce

  1. Postgres: f = select 1 as id, 2.5 as amount, documenting id, amount; r = with q as (select * from f) select distinct(amount)::numeric, id from q; child = select * from r.
  2. Run column_reach or column_answer for r.amount: it throws "r has no column amount; its columns are id".
  3. The other shapes above reproduce the same way, each in r's SELECT list.

Screenshot and/or share link

No response

Operating System

Any

Terminal

Any

ralphstodomingo avatar Nov 17 '26 08:11 ralphstodomingo

Resolved in v0.12.12.

sahrizvi avatar Nov 21 '26 11:11 sahrizvi