Repository navigation
Docs: Document incremental append scans - #4524
smaheshwar-pltr wants to merge 7 commits into
Conversation
Add an API docs section for incremental_append_scan: a worked example, optional and inclusive range bounds, reading new rows since the last run, the shared scan arguments, and the caveat that only append snapshots are read, so it is not a changelog scan. Say the same in the scan docstrings and document the precondition of ancestors_between_ids. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cut the section down to the snapshot range and the append-only caveat, and drop the docstring rewording that isn't needed for the docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| ).to_arrow() | ||
| ``` | ||
|
|
||
| Both bounds are optional. Without a start, the scan reads from the beginning of the table's history, and without an end, up to the current snapshot. The start must be an earlier snapshot in the end snapshot's history, or a `ValueError` is raised. |
There was a problem hiding this comment.
A few things about this paragraph:
- Without a start, the scan begins at the oldest ancestor of the end snapshot that hasn't been expired, not at the start of the table's whole history. These differ after expiry or a rollback, or when
to_snapshot_id_inclusiveisn't the current snapshot. Maybe "from the end snapshot's oldest ancestor"? - The common polling pattern is to save the last snapshot you read and pass it back as
from_snapshot_id_exclusive. If nothing has been committed since, that start equals the current snapshot, and the scan raises:"Earlier snapshot" technically covers this, but a note telling readers to compare againstValueError: Starting snapshot (exclusive) … is not a parent ancestor of end snapshot …tbl.current_snapshot()first would save them a surprise. - On the other hand, the exclusive start doesn't need to exist in the metadata anymore. An expired snapshot works as long as it's the parent of a snapshot that's still there, which is worth mentioning for consumers resuming from a saved snapshot ID.
There was a problem hiding this comment.
An expired snapshot works as long as it's the parent of a snapshot that's still there, which is worth mentioning for consumers resuming from a saved snapshot ID.
#4206 is still open here, so this actually doesn't work if PyIceberg is the one that does expiration. I wouldn't want to provide a note like this when it's not supported, so perhaps we can wait for that fix to merge?
|
|
||
| Both bounds are optional. Without a start, the scan reads from the beginning of the table's history, and without an end, up to the current snapshot. The start must be an earlier snapshot in the end snapshot's history, or a `ValueError` is raised. | ||
|
|
||
| It takes the same filtering and projection arguments, and has the same output methods, as [`scan()`](#query-the-data). |
There was a problem hiding this comment.
This isn't quite the same as scan():
count()lives onDataScan, soIncrementalAppendScandoesn't have it.- The "Query the data" section describes REST server-side scan planning (
scan-planning-mode=server). The incremental scan always plans on the client, even when the catalog or table asks for server-side planning.
Could we narrow the sentence to the methods it supports (to_arrow, to_arrow_batch_reader, to_pandas, to_duckdb, to_ray, to_polars) and mention that it's always planned on the client? Adding server-side planning support could be a follow-up, since the REST plan request already accepts a start and end snapshot.
There was a problem hiding this comment.
Sounds good!
| from_snapshot_id_exclusive=from_snapshot_id, | ||
| to_snapshot_id_inclusive=to_snapshot_id, | ||
| ).to_arrow() | ||
| ``` |
There was a problem hiding this comment.
Nit: it might be worth mentioning the builder methods too, especially from_snapshot_id_inclusive(), since the keyword arguments only offer an exclusive start:
tbl.incremental_append_scan().from_snapshot_id_inclusive(snapshot_id).to_arrow()There was a problem hiding this comment.
We don't usually seem to document the builder APIs in this file (though I'm not sure why) but I do agree and have added builder API docs below 👍
Say where the scan starts without a start snapshot, that a start equal to the end raises, how to include the start snapshot, which output methods it has, and that it's always planned on the client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # mkdocs/docs/api.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thank you for the review, comments should be addressed! cc @Fokko @kevinjqliu |
Rationale for this change
incremental_append_scan()wasn't documented, so this adds a short section after "Query the data" that covers the snapshot range and warns that onlyappendsnapshots are read, so the scan doesn't reflect deletes or updates.I've also added a short note about this on the method's docstring.
Are these changes tested?
N/A (but
make docs-buildpasses)Are there any user-facing changes?
Docs only change.