dr_contract_update()
Adds or replaces declared column types without reading data or executing
rules. New columns are optional unless explicitly included in
required.
Change id for a derived product, or version for a revised definition of
the same contract. The original specification is unchanged.
Usage
dr_contract_update(
x,
id = x$id,
version = x$version,
columns = NULL,
remove = character(),
...
)Arguments
- x
- A confirmed contract specification.
- id, version
- Identifier and definition version. At least one must differ
from
x; version ordering is not inferred. - columns
- Named type vector or zero-length prototypes to add or replace,
as in
dr_contract(). Omit to retain the declared types. - remove
- Character vector of declared column names to remove.
- ...
- Named contract fields to replace in full, such as
required,key,grain,rules,ownerorcolumn_metadata.
Value
A new
contract specification. Use dr_contract_diff() to review it.
Details
Contracts describe final output expectations. Deferred dplyr transformations
do not rewrite them. After renaming, remove the old column and add the new
one here. After aggregation, explicitly set the new
Existing rules must be explicitly replaced or reaffirmed with
grain and key.
A changed grain requires an explicit key, including character() when no
key is claimed. Removing or changing a key column also requires an explicit
key. Removing a required column requires an explicit required vector.Existing rules must be explicitly replaced or reaffirmed with
rules after
a removal, type change or grain change. Rules may contain arbitrary R code,
so their dependencies cannot safely be inferred. This review prevents silent
inheritance of guarantees, but is not proof that revised rules are correct.
Metadata for removed columns is discarded; other metadata is inherited.
Examples
orders <- dr_contract("orders", columns = c(id = "integer"), key = "id")
enriched <- orders |>
dr_contract_update(id = "enriched_orders", columns = c(channel = "character"))
dr_contract_diff(orders, enriched)See also
Documentation source snapshot · View source at d9cb454 ↗
Code examples are documented source examples; they are not executed in this website build.
Code examples are documented source examples; they are not executed in this website build.