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

[BUG]: column answer mishandles some column names at the edges

Open ralphstodomingo opened this issue 2 weeks ago • 2 comments

Description

impact_analysis's column answer and dbt_lineage mishandle some column names, which a review of #1710 found. No model is ever reported unaffected; these are wrong names, "has no column" errors, or a missing column.

  • A real column named _1 that a select * child inherits is dropped from the child: columnReach(child, "_1") throws "has no column".
  • A real alias named like the engine's own _N loses its edge when the engine also gives a _col_N for the same source column.
  • select *, val as id settles without the id_1 DuckDB makes, so id_1 throws "has no column".
  • A COLUMNS() call anywhere in the SQL makes a real "col_\0" alias disappear.
  • On Postgres and Redshift an unaliased cast of a column (amount::numeric) is named after the column, but the answer labels it _col_1, so the trace stops there.
  • DuckDB names a join's second val val_1; dbt_lineage for a select * child misses it.
  • The text line "K of them with no sign (not traced)" can read as "no effect".

Plugins

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

OpenCode version

main after #1710.

Steps to reproduce

  1. DuckDB: f documents id, amount; r = select id, amount as _1 from f; child = select * from r.
  2. Run columnReach(child, "_1"): it throws "child has no column _1".
  3. The other shapes above reproduce the same way, each with its one-line model.

Screenshot and/or share link

No response

Operating System

Any

Terminal

Any

ralphstodomingo avatar Nov 16 '26 04:11 ralphstodomingo

Deferred from #1754, for a follow-up. None is a regression against the current release; each under-traces or mislabels edge input, and nothing is reported unaffected:

  • A repeat beside a qualified or CTE-wrapped star (select f.*, val as id from f f, with q as (select *, val as id from f) select * from q) still settles, so r.id_1 gives "has no column" on DuckDB, as before. Only a bare outer * is checked.
  • A written _N/_col_N is looked for anywhere in the SQL, so a table alias or WHERE column with that name keeps the engine's label (a _1 table alias keeps a fake _1; a _col_1 relation stops a cast rename).
  • distinct on (...) with nested parentheses, and mixed cast chains (cast(amount as numeric)::int), keep _col_N.
  • Aliases after t.mod or a complete interval literal (t.mod id, interval '1 day' id) aren't read.
  • dbt_lineage shows a model's own cast edge under the engine's label while column_answer names it after the column.

ralphstodomingo avatar Nov 16 '26 13:11 ralphstodomingo

Resolved in v0.12.12.

sahrizvi avatar Nov 21 '26 11:11 sahrizvi