fix(meerkat-core): qualify lookup columns to stop ambiguous CSV export (ISS-301213)#280
fix(meerkat-core): qualify lookup columns to stop ambiguous CSV export (ISS-301213)#280jayachandranramadoss-devrev wants to merge 1 commit into
Conversation
…t (ISS-301213) CSV export from dashboard widgets failed with `Binder Error: Ambiguous reference to column name` when a base query joined multiple lookup tables that share a raw column name (e.g. `deprecated_created_by_agent_id` on both `dim_devu` and `dim_group`, seen on the Razorpay Incident dashboard / TKT-65015). Each resolution lookup is joined as `SELECT <named cols>, * FROM (<lookupSql>)`. The trailing bare `*` re-exposed every raw column of the lookup, so a column name shared across two lookups appeared twice in the intermediate join relation and the binder rejected the export. Fix: rewrite each lookup table's SQL so it projects its declared dimensions (plus the join column) under a globally-unique table-qualified alias `<config>__<column>`. The bare `*` then only ever surfaces uniquely-named columns, so the ambiguity cannot occur. The resolution dimension `.sql` and the join ON clause are updated to reference the same qualified aliases. This is an alternative to the post-hoc narrowing approach in PR #272: it keeps every declared lookup column available (renamed) rather than dropping unreferenced ones, and disambiguates even shared *declared* column names. Test plan: - New regression test asserts each lookup column is projected under a distinct qualified alias and the export COPYs with resolved values intact. - meerkat-core: 549 passed. meerkat-node: 906 passed. meerkat-browser: 2 passed.
|
Why this fix lives in meerkat, not devrev-webA reasonable question: the lookup table SQL is built in devrev-web ( No — a devrev-web-only rename breaks the join. The column references are generated inside meerkat, by raw column name:
If devrev-web renamed the lookup's projected columns to qualified aliases ( This fix avoids that wall by changing both ends in the same repo: the lookup projects The only devrev-web-only change that would work without a meerkat release is narrowing (dropping unused passthrough columns like Rollout noteProduction currently ships |
Summary
Binder Error: Ambiguous reference to column namewhen resolution joins multiple lookup tables that share a raw column name (e.g.deprecated_created_by_agent_idon bothdim_devuanddim_group— Razorpay Incident dashboard, TKT-65015).SELECT <named cols>, * FROM (<lookupSql>). The trailing bare*re-exposes every raw column of the lookup, so a name shared across two lookups appears twice in the intermediate join relation and DuckDB's binder rejects the export.<config>__<column>. The bare*then only ever surfaces uniquely-named columns, so the ambiguity cannot occur.Why not PR #272's narrowing
PR #272 narrows each lookup to only the join + resolution columns (drops the rest). This PR instead renames every declared column to a unique qualified alias — it keeps all declared lookup columns available and also disambiguates shared declared column names, not just undeclared passthrough ones.
Changes
generate-resolution-schemas.ts: addbuildQualifiedLookupSql(projects<wrapAlias>."<col>" AS "<config>__<col>"), andresolutionJoinColumnAliashelper; resolution dimension.sqlnow references the qualified alias.resolution.ts: join ON clause references the qualified join-column alias.resolution.spec.ts(core + node),generate-resolution-schemas.spec.ts,resolution-step.spec.ts.resolution-shared-column-ambiguity.spec.tsregression test.DevRev
work-item: ISS-301213
Test plan
🤖 Generated with Claude Code