Repository navigation
docs: declare history tables with a required_filter on the validity column - #166
Merged
Merged
Conversation
…olumn A history (slowly changing) table declared many_to_one silently multiplies facts when joined on the key alone: every version matches, nothing errors, and the fan-out check stays quiet because the declared cardinality is many_to_one. The existing required_filter already covers it — a filter on valid_to flags the key-only join and accepts both the current-version and the as-of join — but nothing said so. Adds a "History tables" recipe to the README and TestHistoryTable to pin the behaviour it describes, including the silent case that motivates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #166: the agent sees required_filter as a condition it must apply, so `valid_to IS NULL` beside an as-of description contradicted itself. The recipe now declares one rule — as of the fact's date with a half-open interval, or the current version — as the required_filter. The as-of rule also flags a current-only join and a missing lower bound. Drops the "same total" claim, which fails for inner joins, and states the limitations of a name-based check: another table's column satisfies it, a multi-version filter satisfies the current rule, and a correct as-of LEFT JOIN warns on the preserved-side order_date. Each is pinned by a test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
many_to_onedouble-counts when joined on the key alone: every version matches, nothing errors, and the fan-out check stays silent.required_filter, which the agent sees as a condition it must apply.order_date >= valid_from AND (valid_to IS NULL OR order_date < valid_to)valid_to IS NULLWHEREorON. The as-of rule also flags a current-only join and a missing lower bound.valid_to IS NOT NULL) satisfies the current rule, and a correct as-ofLEFT JOINstill warns on the preserved-sideorder_date.TestHistoryTable(12 tests) pins every case and every limitation the recipe states.Docs and tests only; no library change, no release. Follow-up candidate, not in this PR: count a preserved-side column in an outer join's
ONwhen its predicate also references the null-extended side, which would clear the as-ofLEFT JOINfalse warning.Test plan
uv run pytest(3,257 passed)prek run --all-filesclean🤖 Generated with Claude Code