## io.SourceBatch


What a versioned source has between a recorded version and its latest


Usage

``` python
io.SourceBatch(
    start,
    end,
    snapshot_facts,
    changes=None,
    facts=list(),
    trusted="",
    kind="change_feed",
    snapshot=None,
    fallback=None,
    schema=None
)
```


one: what [VersionedSource.changes](io.VersionedSource.md#sverify.io.VersionedSource.changes) returns.

Either [changes](io.Source.md#sverify.io.Source.changes) from the format's change feed (the net change, with [facts](io.Snapshot.md#sverify.io.Snapshot.facts) about the inserted rows and the [trusted](io.SourceBatch.md#sverify.io.SourceBatch.trusted) assumption it rests on), or the new [snapshot](io.Source.md#sverify.io.Source.snapshot) alone with the reason the feed is unavailable (`fallback`). Build one with [unchanged](io.SourceBatch.md#sverify.io.SourceBatch.unchanged), [from_changes](io.SourceBatch.md#sverify.io.SourceBatch.from_changes) or [from_snapshot](io.SourceBatch.md#sverify.io.SourceBatch.from_snapshot).


## Attributes


`start: int`  
The version the batch starts from (`since`).

`end: int`  
The version it reaches.

`snapshot_facts: list[Fact]`  
What the metadata says about every row at `end`.

`changes: Changes | None`  
The change, or None with [snapshot](io.Source.md#sverify.io.Source.snapshot).

`facts: list[Fact]`  
What the metadata says about the inserted rows.

`trusted: str`  
What the change rests on, for the refresh report.

`kind: Literal[``"change_feed", `<span class="st">`"snapshot_diff"``]`</span>  
`"change_feed"` (trusted) or `"snapshot_diff"` (exact).

`snapshot: pa.Table | None`  
The table at `end`, when there is no change.

`fallback: str | None`  
Why there is no change, with [snapshot](io.Source.md#sverify.io.Source.snapshot).

`schema: pa.Schema | None`  
The table's schema at `end`; None: the one recorded.


## Methods

| Name | Description |
|----|----|
| [from_changes()](#from_changes) | The change from `since` to `until`, as rows inserted and deleted. |
| [from_snapshot()](#from_snapshot) | No change is available from `since`: the whole table at `until` |
| [unchanged()](#unchanged) | No change: the table is still at `version`. |

------------------------------------------------------------------------


#### from_changes()


The change from `since` to `until`, as rows inserted and deleted.


Usage

``` python
from_changes(
    since,
    until,
    *,
    inserts=(),
    deletes=(),
    trusted,
    facts=(),
    snapshot_facts=(),
    kind="change_feed",
    schema=None
)
```


##### Parameters


`since: int`  
The version the change starts from.

`until: int`  
The version it reaches.

`inserts: pa.Table | Sequence[Row] = ()`  
Rows added: an Arrow table, or tuples in column order.

`deletes: pa.Table | Sequence[Row] = ()`  
Rows removed, one copy each, in the same forms.

`trusted: str`  
What the change rests on, shown in the refresh report, such as `"Δ trusted as coming from Delta CDF v3→v5"`.

`facts: Sequence[Fact] = ()`  
What the metadata says about the inserted rows. Default: none (preconditions are checked on the rows).

`snapshot_facts: Sequence[Fact] = ()`  
What the metadata says about every row at `until`. Default: none.

`kind: Literal[``"change_feed", `<span class="st">`"snapshot_diff"``]`</span>` = ``"change_feed"`  
`"change_feed"` (the change is trusted) or `"snapshot_diff"` (it was computed from two snapshots, so it is exact).

`schema: pa.Schema | None = None`  
The table's schema at `until`, which the rows have. Default: the one recorded.


##### Returns


`SourceBatch`  
The batch.


------------------------------------------------------------------------


#### from_snapshot()


No change is available from `since`: the whole table at `until`


Usage

``` python
from_snapshot(since, until, table, *, reason, snapshot_facts=(), schema=None)
```


instead. The refresh diffs it against the state, and recomputes the nodes reading it.


##### Parameters


`since: int`  
The version the change would start from.

`until: int`  
The version of [table](Node.table.md#sverify.Node.table).

`table: pa.Table`  
The table at `until`.

`reason: str`  
Why there is no change, shown in the refresh report.

`snapshot_facts: Sequence[Fact] = ()`  
What the metadata says about every row of [table](Node.table.md#sverify.Node.table). Default: none.

`schema: pa.Schema | None = None`  
The table's schema at `until`. Default: [table](Node.table.md#sverify.Node.table)'s.


##### Returns


`SourceBatch`  
The batch.


------------------------------------------------------------------------


#### unchanged()


No change: the table is still at `version`.


Usage

``` python
unchanged(version, facts=(), schema=None)
```


##### Parameters


`version: int`  
The version asked for as `since`, and still the latest.

`facts: Sequence[Fact] = ()`  
What the metadata says about every row. Default: none.

`schema: pa.Schema | None = None`  
The table's schema. Default: the one recorded.


##### Returns


`SourceBatch`  
A batch from `version` to `version`.
