Skip to content

Fix member_months extension passthrough double-strip (#1347)#1349

Open
gopidaxhealthcaresolutions wants to merge 2 commits into
tuva-health:mainfrom
gopidaxhealthcaresolutions:fix/1347-member-months-passthrough-strip
Open

Fix member_months extension passthrough double-strip (#1347)#1349
gopidaxhealthcaresolutions wants to merge 2 commits into
tuva-health:mainfrom
gopidaxhealthcaresolutions:fix/1347-member-months-passthrough-strip

Conversation

@gopidaxhealthcaresolutions

Copy link
Copy Markdown

@

Closes #1347

What happens

With passthrough.strip: true and an extension column on eligibility (e.g. ext_cell_phone), the member_months models fail to compile:

invalid identifier A.EXT_CELL_PHONE

Why

The prefix gets stripped twice. select_extension_columns() always discovers column names by introspecting the original input relation (e.g. normalized__eligibility), so it keeps asking for ext_cell_phone. But an upstream CTE has already renamed that column to cell_phone via the first (stripping) call, so the second call references a column that no longer exists.

Fix

This follows the convention already used by every other intermediate model in the repo (e.g. int_eligibility_casting, core__int_patient_casting, the core__stg_claims_* models): intermediate models pass strip_prefix=false so the prefix is preserved end-to-end (and downstream introspection can still identify the extension columns by prefix), and only the final model strips.

The prefix should be stripped exactly once, at the final output (core__member_months, which already calls the macro with the default strip behavior). This PR adds strip_prefix=false to the four intermediate call sites that were missing it:

  • models/core/staging/core__int_member_months.sql (2 calls: stg_eligibility, joined)
  • models/core/staging/core__stg_claims_member_months.sql (2 calls)

Behavior impact

  • Default config (strip: false): no change — extension columns keep their prefix through the whole chain, exactly as before.
  • strip: true: previously a hard compile failure; now compiles and the prefix is stripped once in the final core__member_months output.

Testing

Reproduced both the failure and the fix locally on DuckDB with a focused project mirroring the exact double-call CTE chain (intstgfinal) and an ext_-prefixed eligibility column:

  • Before (strip: true): Binder Error: Values list "a" does not have a column named "ext_cell_phone" — matches the reported bug.
  • After (strip: true): chain compiles and runs; final output column is cell_phone (stripped once), data intact.
  • After (strip: false, default): final output column is ext_cell_phone (preserved) — confirms no regression for existing users.

The existing extension_column_unit_tests.yml unit tests for this chain also pass.
@

@netlify

netlify Bot commented Jun 22, 2026

Copy link
Copy Markdown

Deploy Preview for thetuvaproject canceled.

Name Link
🔨 Latest commit f92e5dd
🔍 Latest deploy log https://app.netlify.com/projects/thetuvaproject/deploys/6a4725a5c933fe000876c4a1

The member_months chain stripped the passthrough prefix in an early CTE
and then asked select_extension_columns() for the original prefixed name
again from a CTE that no longer had it, breaking compilation when
passthrough.strip is true (invalid identifier on the prefixed column).

Follow the established convention: intermediate models pass
strip_prefix=false so the prefix is preserved (and downstream
introspection can still identify extension columns), and only the final
model (core__member_months) strips. Applies strip_prefix=false to the
four intermediate calls in core__int_member_months and
core__stg_claims_member_months.
@gopidaxhealthcaresolutions
gopidaxhealthcaresolutions force-pushed the fix/1347-member-months-passthrough-strip branch from 254e8de to 8deb36b Compare June 22, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 👀 Ready for Review

Development

Successfully merging this pull request may close these issues.

member_months extension passthrough breaks when passthrough.strip: true

1 participant