Filters or redacts columns based on a YAML-driven field policy. This is the same logic the MCP server uses to strip PII before data reaches the AI model.
Arguments
- df
A data frame (typically from
bs_get_dataset()).- dataset_name
Character string identifying the BDS dataset.
- policy
A named list representing the field policy (as returned by
yaml::read_yaml()). IfNULL(the default), loads the bundledfield_policy.ymlshipped with the package.
Details
The policy supports three modes per dataset:
allowOnly the listed fields are kept; all others are dropped.
redactThe listed fields have their values replaced with
"[REDACTED]"; all other fields pass through.allAll columns pass through unchanged.
If dataset_name is not found in the policy, the data frame is returned
unchanged.
Examples
df <- data.frame(
UserId = 1L, FirstName = "Jane", Organization = "Org1",
stringsAsFactors = FALSE
)
bs_apply_field_policy(df, "Users")
#> Error in bs_apply_field_policy(df, "Users"): could not find function "bs_apply_field_policy"