dr_dbt_contract()
Create an ordinary YAML-ready list containing explicit column types,
not-null tests and a single-column unique-key test. The default SQL types
target dbt-duckdb. Other adapters can supply explicit
types overrides.
This does not install dbt packages, modify a project or execute validation.
Usage
dr_dbt_contract(
contract,
name,
enforced = TRUE,
types = NULL,
unsupported = c("error", "report")
)Arguments
- contract
- A
dataraft.core::dr_contract()specification. - name
- dbt model identifier.
- enforced
- Whether dbt should enforce the exact model schema.
- types
- Optional named character vector overriding SQL types by column.
For example,
c(amount = "decimal(18,2)"). Nested R list columns require an explicit SQL type because their shape cannot be inferred fromlist. - unsupported
- How to handle checks that cannot be translated:
"error"(default) or"report"with a warning and metadata.
Value
A regular list with
version = 2 and one models entry, suitable
for yaml::write_yaml() or composition into dbt model properties.
Details
Schema enforcement is supported for SQL models with compatible dbt
materializations. It enforces the exact exported names and types. Required
fields and keys use dbt data tests, whose execution is the responsibility of
R functions, formulas, pointblank rules and composite-key checks are not translated. By default they cause an error. With
dbt build or dbt test; no database constraint guarantee is implied.R functions, formulas, pointblank rules and composite-key checks are not translated. By default they cause an error. With
unsupported = "report",
a warning names them and config.meta.dataraft.untranslated records them
in the exported model. Missing SQL types always cause an error. R lifecycle
policies such as empty-data, freshness and additional-column handling are
recorded separately under r_policies; they still require R validation.
The export is deliberately a bounded schema bridge, not a replacement for
the original contract or its quality engines.
Examples
schema <- dataraft.core::dr_contract(columns = c(id = "integer", amount = "numeric"), key = "id")
properties <- dr_dbt_contract(schema, "orders")
properties$models[[1]]$columnsSee also
Documentation source snapshot · View source at 3a9d744 ↗
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.