DRDataRaft/ docs
GitHub ↗

dr_compare()

With only an asset name, compares its latest two releases and uses the latest published contract's key. Supply key for structural-only assets. Counts and numeric totals run in the database. Only bounded row previews are collected; limit = Inf explicitly collects all differences.

Usage

dr_compare(lake, name, from = NULL, to = NULL, key = NULL, limit = 100)

Arguments

lake
Connected lake, including a read-only connection, or the earlier published result. With two results, their exact releases are compared and an owned read-only connection is closed automatically.


name
Published asset name, or the later published result.


from, to
Optional release IDs. Defaults to the previous and latest releases. When only to is given, from is its preceding release.


key
Optional business-key column names.


limit
Maximum rows in each added, removed and changed preview.

Value

A dr_comparison list with release IDs, counts, schema differences, numeric totals, and row previews. Changed previews contain separate before and after tables in the same key order.

Details

Keys must be unique and non-missing in both releases. Missing values compare equal. Integer and numeric columns are compatible. A schema change marks every matched row as changed. Numeric totals ignore missing values, whose counts are reported separately. Row order has no significance.

Examples

\dontshow{if (requireNamespace("duckdb", quietly = TRUE)) withAutoprint(\{ # examplesIf}
root <- tempfile("dataraft-")
lake <- dr_open_lake(root)
dr_write_data(lake, data.frame(id = c(1L, 2L), amount = c(10, 20)), "orders")
dr_write_data(lake, data.frame(id = c(1L, 3L), amount = c(12, 30)), "orders")
difference <- dr_compare(lake, "orders", key = "id")
difference
difference$changed
dr_close_lake(lake)
unlink(root, recursive = TRUE)
\dontshow{\}) # examplesIf}
Documentation source snapshot · View source at 113c179 ↗
Code examples are documented source examples; they are not executed in this website build.

Search documentation

Search functions, packages and guides.