Skip to content

Warn when a dataset carries columns that match no variable - #531

Merged
MaxGhenis merged 1 commit into
masterfrom
dataset-unknown-column-warning
Aug 14, 2026
Merged

Warn when a dataset carries columns that match no variable#531
MaxGhenis merged 1 commit into
masterfrom
dataset-unknown-column-warning

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Fixes #530.

Both dataset-load branches in Simulation.build_from_dataset silently dropped columns whose variable name isn't in the tax-benefit system — one carried a literal # Silently skip. comment. Consequence: any country-model input removal or rename silently zeroes that data for every existing dataset, which is the blocker behind policyengine-us#9275's staged removal of deprecated inputs (context: policyengine-us#9276, microcosm#673).

This collects the skipped names in both branches and emits one aggregated warning naming them (first ten + count) after the load, e.g.:

The dataset contains 2 column(s) that do not match any variable in the tax-benefit system and were ignored: first_home_mortgage_interest__2024, second_home_mortgage_interest__2024

Behavior is otherwise unchanged: known columns load exactly as before, unknown ones are still skipped (not fatal), and clean datasets stay quiet. Tests cover the warn-and-still-load case and the no-false-positive case on the flat-file path (Dataset.from_dataframe + country-template Microsimulation); the TIME_PERIOD_ARRAYS branch shares the same accumulator.

A strict mode that raises instead (for certification harnesses) is left as a follow-up if wanted — #530 sketches it.

🤖 Generated with Claude Code

Fixes #530.

Both dataset-load branches in Simulation.build_from_dataset silently
dropped columns whose variable name is not in the tax-benefit system —
one carried an explicit "Silently skip" comment. That makes any
country-model input removal or rename silently zero the affected data
for every existing dataset (the blocker for
policyengine-us#9275's deprecated-input removals).

Collect the skipped column names in both branches and emit one
aggregated warning naming them (first ten, plus a count), so a
version-mismatched dataset announces itself instead of loading as if
nothing happened. Known columns load exactly as before, and clean
datasets stay quiet — both covered by new tests on the flat-file path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@MaxGhenis
MaxGhenis merged commit 04478e0 into master Aug 14, 2026
22 checks passed
@MaxGhenis
MaxGhenis deleted the dataset-unknown-column-warning branch August 14, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dataset loader silently skips h5 columns for unknown variables — warn (or optionally raise)

1 participant