Add complete= so wide-era census zeros are recoverable after sparsification
#18
Closed
opened 2026-07-29 19:57:52 -04:00 by jared
·
1 comment
No Branch/Tag Specified
main
ci/mirror-canonical-tags
chore/release-47-badges-mirror-pr
docs/readme-perf-remeasure-56
feat/pagination-search-balances-57
feat/duckdb-threads-60
feat/cohort-predicates-58
fix/windows-backslash-paths
ci/mirror-to-github
ci/github-actions-matrix
feat/public-release-0.3.0
chore/fixture-sb203
ci/apt-https
fix/pushdown-pagination
feat/all-categories-37
fix/partial-coverage-signposting-9
fix/schema-v7
fix/cog-categories-balance-subtype
feat/cog-balances-25
feat/revenue-concepts-12
feat/expenditure-concepts-11
feat/coverage-disclosure-13
feat/complete-argument-18
fix/kodor-batch-14-15-16
fix/all-scoped-series-breaks-19
fix/regen-fixture-corpus-18
test/walkthrough-findings
feat/expenditure-concept
fix/3-url-trailing-slash
feat/phase-r3-signposting
fix/fixture-option-b-aggregates
feat/phase-r2-harmonization
feat/phase-r1-forward
feat/cog-gov-search-basket-mode
v0.4.0
Labels
Clear labels
kodor
kodor/feature-proposal
kodor/fix
kodor/needs-review
kodor/triaged
madison-walkthrough
severity/high
severity/low
severity/medium
south-guide
verdict/defect
verdict/definitional
kodor
kodor/feature-proposal
kodor/fix
kodor/needs-review
kodor/triaged
Kodor should process this issue
Kodor has written a feature proposal
Kodor should implement a fix (assigned to Kodor)
Kodor's work or failure needs Jared's review
Kodor has already triaged this issue (skip)
Surfaced while building the client-facing Southern API guide
needs
human
Cannot move without a person -- a decision, a check an agent cannot make, something outside the repo
origin
client
Came from a client ask
origin
obligation
Created by a change elsewhere
origin
review
Came from human review
origin
roborev
Promoted from a roborev finding
type
chore
Maintenance with no behaviour change
type
debt
Owed work -- docs, tests, cleanup a change obligated
type
decision
Needs a decision before work can proceed
type
defect
Something is wrong
type
feature
New capability
ws
api
Query verbs and results
ws
corpus
Corpus, mirror, provenance
ws
docs
Vignettes and guides
Assign a task to kodor
Kodor thinks this needs a feature.
Kodor should fix this
Kodor thinks the user is ready to review this.
Kodor is done with this issue.
No labels
Milestone
No items
No Milestone
Projects
Clear projects
No projects
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Civilytics/uscogdata#18
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Follow-on from
census_of_governments_finance_pipeline#64DoD 7. Filed after the corpus was sparsified and published on 2026-07-29 (pipeline_commit 83f9715).What changed under us
The published corpus no longer stores the wide era's explicit zeros. 331.4M rows -> 45.9M (-86%). Absence now means two different things:
dense_source)sparse_source)Two new corpus artifacts carry the rule:
data/representation.parquet(per year:representation,absence_means,code_set_id) anddata/code_set.parquet(code_set_id,year,type,item_code,is_aggregate,n_units-- 84,693 rows across 55 years). The government universe is already incanonical_fips_xwalk. Catalogued asSB194.The user-visible consequence
A wide-era query whose rows were all
$0now returns nothing instead of$0rows, and the reader offers no way to get them back. Verified against the live corpus:cog_spending(govid="552025209777", years=2005L)returns 27 rows, 0 of them zero-amount. Before sparsification the all-zero categories came back as explicit$0.This is strictly less information than the reader used to expose, which is why #64 filed this follow-on.
What to build
complete = TRUEon the money verbs: fill the requested grid fromcode_set(scoped to each government'stype-- filling against the union of all types invents rows like "$0 state IG transfer to school districts" for counties) and stamp each row'svalue_source:reportedlongcensus_zeronot_reportedStrictly more information than the reader had before sparsification, where a wide-era zero and a modern absent cell were different shapes with nothing explaining the difference.
Prerequisite
The bundled fixture corpus is stale and must be regenerated first.
inst/extdata/fixture_corpus/has noJrows insummary_categories(it predates the #65 crosswalk work), norepresentation.parquet, nocode_set.parquet, and a still-dense wide era. Every test in this package and in cog-api runs against it, so it currently does not represent what is published.Definition of done
complete=implemented oncog_spending()/cog_revenue(), defaulting to today's behaviour.value_sourceon every returned row whencomplete = TRUE.complete = TRUEreproduces the pre-sparsification row set exactly, zeros included.cog-apifollow-on filed (threadingcomplete=behind its own pagination fixes).The pipeline asserts this same round-trip on every build -- see
tests/testthat/test-end-to-end.Rin that repo for the reference implementation of the densification.Reopened. PR #20 landed DoD 1 only — the fixture regeneration this issue names as its prerequisite. My PR body said "closes #18's stated prerequisite" and Gitea's keyword parser took the
closes #18out of it; my mistake.Still open:
pipeline_commit 83f9715, wide era sparse,representation.parquet+code_set.parquetnow shipped).complete=oncog_spending()/cog_revenue(), defaulting to today's behaviour.value_source(reported/census_zero/not_reported) on every row whencomplete = TRUE.complete = TRUEreproduces the pre-sparsification row set exactly, zeros included.complete=behind its own pagination fixes — cog-api#6).The fixture now carries everything DoD 2-4 need, so the remaining work is self-contained. Note the reader has no views over
representation/code_setyet: the parquets ship in the fixture and the publish tree, butinst/sql/registers nothing for them, so step 2 starts with two new view definitions.