altimate-code
altimate-code copied to clipboard
[BUG]: column answer throws "has no column" for a cast after a SELECT modifier or in parentheses
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, idand Redshift'sselect top 5amount::numeric, id. distinct onwith 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_1label, 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
- Postgres:
f = select 1 as id, 2.5 as amount, documentingid, amount;r = with q as (select * from f) select distinct(amount)::numeric, id from q;child = select * from r. - Run
column_reachorcolumn_answerforr.amount: it throws "r has no column amount; its columns are id". - 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
Resolved in v0.12.12.