Comparison.slice_diffs#

Comparison.slice_diffs(
table: str,
columns: Sequence[str] | None = None,
) DuckDBPyRelation#

Return rows from one table that differ in the selected columns.

Parameters:
tablestr

Table identifier to return (one of table_id).

columnssequence of str, optional

Columns to check for differences. Defaults to all comparable columns.

Returns:
duckdb.DuckDBPyRelation

Relation with the full schema of the requested table.

Examples

>>> from versus import compare, examples
>>> comparison = compare(
...     examples.example_cars_a(),
...     examples.example_cars_b(),
...     by=["car"],
... )
>>> comparison.slice_diffs("a", ["mpg"])
┌────────────┬──────────────┬───────┬───────┬───────┬──────────────┬──────────────┬───────┬───────┐
│    car     │     mpg      │  cyl  │ disp  │  hp   │     drat     │      wt      │  vs   │  am   │
│  varchar   │ decimal(3,1) │ int32 │ int32 │ int32 │ decimal(3,2) │ decimal(3,2) │ int32 │ int32 │
├────────────┼──────────────┼───────┼───────┼───────┼──────────────┼──────────────┼───────┼───────┤
│ Duster 360 │         14.3 │     8 │   360 │   245 │         3.21 │         3.57 │     0 │     0 │
│ Merc 240D  │         24.4 │     4 │   147 │    62 │         3.69 │         3.19 │     1 │     0 │
└────────────┴──────────────┴───────┴───────┴───────┴──────────────┴──────────────┴───────┴───────┘