Skip to content

[BUG]: column answer misreads escape strings, quoted and Unicode names, and collate in a model's SQL #1852

In review

Description

@ralphstodomingo

Description

Follow-ups from the reviews of #1754 and #1760: how impact_analysis's column answer and dbt_lineage read a model's SQL text. Nothing is reported unaffected; these are wrong or missed names.

  • A Postgres escape string with a backslash-escaped quote (E'it\'s, (b)::int, example') ends early when the text is read, so the SELECT items shift and a real cast can take another column's name.
  • An alias without AS is missed after a column that reads like an operator (t.mod id) and after a complete interval literal (interval '1 day' id).
  • A quoted name doesn't drop its doubled quote ("a""b" reads as a""b), and a name in another script (allé, 日本) isn't read as a name.
  • amount::text collate "C" keeps the engine's _col_N label on Postgres and Redshift, though Postgres names it amount.
  • The cast reader has no bound on nested parentheses: 50,000 of them overflow the stack.
  • The word lists behind three of these checks are separate copies that have drifted apart.

Plugins

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

OpenCode version

v0.12.12 (main).

Steps to reproduce

  1. Postgres: f = select 1 as id, 2 as b, 3 as c; r = select id, E'it\'s, (b)::int, example', c::int, b as b from f; child = select * from r.
  2. Run column_answer for f.c: it answers r.b → child.b, where the value lands in r.c.
  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

Activity

  1. added
    bug
    on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions