This chapter runs the first complete workflow against the same synthetic policy data used throughout the book. It stays in memory so that the acceptance logic is visible before persistence is introduced.
# A tibble: 1 × 4
policy_id broker_id premium status
<int> <int> <dbl> <chr>
1 2 20 -20 paid_up
write = FALSE skips the configured DataRaft writer. stop_on_failure = FALSE returns the blocked result so the evidence remains inspectable.
The useful result is not only “the code failed.” The useful result identifies the acceptance rule that failed and, for a row predicate, the rows involved.
4.4 Correct and collect
Run the unchanged product definition against the valid fixture.
good <-dr_run( policies,data = policy_delivery,write =FALSE)good$status
[1] "completed"
accepted <-dr_collect(good)accepted
# A tibble: 4 × 4
policy_id broker_id premium status
<int> <int> <dbl> <chr>
1 1 10 1200. active
2 2 20 950. paid_up
3 3 10 601. lapsed
4 4 30 1500 active
dr_collect() accepts executed results, not product definitions. That distinction creates a small trust boundary: downstream code asks for data only after the delivery has passed the configured gate.
4.5 Read the result as evidence
A run result carries more than rows. It records status, validation status, timestamps, inputs, outputs, warnings, quality evidence, and an inspected copy of the definition.
The placeholder incoming_delivery represents the next delivery in your own process. The executable examples above use the checked-in fixture.
WarningA successful R expression is not an accepted delivery
The important status is the DataRaft run status and its checks, not whether the R process reached the end of the script.
4.6 Why not publish yet?
Publication answers a second question: where should accepted data live? Keeping this chapter in memory lets you learn the acceptance boundary independently from filesystem, database, or lake semantics.
Chapter 9 will attach a versioned RDS target. The contract and quality rule do not need to change.
4.7 Exercises
Change one premium to a negative value and compare status, the quality report, and affected rows.
Remove premium from the delivery. Explain why that is an interface failure rather than the same kind of failure as a negative premium.
Duplicate a policy_id. Which expectation detects the problem, and why is identity stronger than a column name?