fix: cog_categories() surfaces balance subtypes and accepts type = "balance"
The balance work added category_type = "balance" rows to the corpus and cog_balances() to read them, but left cog_categories() -- the discovery surface -- unable to describe them: - subtype COALESCEd only spend_subtype and revenue_subtype, so every balance row came back with subtype = NA - type rejected "balance", so there was no way to ask for the holdings taxonomy at all Both matter downstream: cog-api derives its subtype vocabulary from cog_categories(), so an NA subtype becomes an unusable API parameter. Found while implementing cog-api#26. Note cog_balances() itself still takes no subtype argument -- for holdings category is a strict coarsening of balance_subtype -- but the value belongs in the discovery surface regardless. Tests read the expected subtype set independently from the crosswalk parquet rather than from the function under test.
This commit is contained in:
+11
-3
@@ -7,8 +7,8 @@
|
||||
cog_categories(type = NULL, pattern = NULL)
|
||||
}
|
||||
\arguments{
|
||||
\item{type}{Either `NULL` (default, return both spending and revenue
|
||||
rows), `"spending"`, or `"revenue"`.}
|
||||
\item{type}{Either `NULL` (default, every row: expenditure, revenue and
|
||||
balance), `"spending"`, `"revenue"`, or `"balance"`.}
|
||||
|
||||
\item{pattern}{Optional regex matched case-insensitively against the
|
||||
`category` column (e.g. `"Police"` or `"Tax"`).}
|
||||
@@ -22,7 +22,15 @@ Tibble with columns `category`, `category_type`, `subtype`,
|
||||
Returns the category taxonomy exposed by the corpus's
|
||||
`summary_categories` view, grouped to one row per
|
||||
`(category, subtype)` pair. Use this to discover valid `category`
|
||||
values for [cog_spending()] / [cog_revenue()] /
|
||||
values for [cog_spending()] / [cog_revenue()] / [cog_balances()] /
|
||||
[cog_geographic_rollup()] and to audit which Census item codes feed
|
||||
each category.
|
||||
}
|
||||
\details{
|
||||
`subtype` COALESCEs the crosswalk's three subtype columns, so it carries
|
||||
`spend_subtype` on expenditure rows, `revenue_subtype` on revenue rows and
|
||||
`balance_subtype` on balance rows. Note that [cog_balances()] itself takes
|
||||
no `subtype` argument — for holdings, `category` is a strict coarsening of
|
||||
`balance_subtype` — but the value is surfaced here because it is the
|
||||
discovery surface downstream consumers build their vocabulary from.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user