This is an automated email from the ASF dual-hosted git repository.
JingsongLi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-rust.git
The following commit(s) were added to refs/heads/main by this push:
new e789f792 [docs] document Python and C binding capabilities already in
code (#1364)
e789f792 is described below
commit e789f792e861f511f22ec17caae1848280b82588
Author: AuroraVoyage <[email protected]>
AuthorDate: Mon Nov 16 21:31:53 2026 +0800
[docs] document Python and C binding capabilities already in code (#1364)
---
bindings/python/project-description.md | 4 +-
docs/src/c-binding.md | 79 +++++++++++++++
docs/src/python-binding.md | 176 ++++++++++++++++++++++++++++++++-
3 files changed, 257 insertions(+), 2 deletions(-)
diff --git a/bindings/python/project-description.md
b/bindings/python/project-description.md
index f1256e9c..19df296a 100644
--- a/bindings/python/project-description.md
+++ b/bindings/python/project-description.md
@@ -289,4 +289,6 @@ updates the identifier's current branch (main by default);
it does not change
the source branch. These catalog methods currently require a REST catalog.
Other catalog implementations raise `NotImplementedError`.
-Time travel queries are not supported in the Python binding at this time.
+Time travel is supported through `Table.new_read_builder(options)` with one of
+`scan.snapshot-id`, `scan.tag-name`, `scan.timestamp-millis`, `scan.timestamp`,
+`scan.watermark`, or `scan.version`. At most one selector may be set.
diff --git a/docs/src/c-binding.md b/docs/src/c-binding.md
index ad2f8469..2ca3b4aa 100644
--- a/docs/src/c-binding.md
+++ b/docs/src/c-binding.md
@@ -198,6 +198,85 @@ paimon_option options[] = {
paimon_result_catalog_new result = paimon_catalog_create(options, 3);
```
+### Time Travel
+
+Create a read builder with scan options through
+`paimon_table_new_read_builder_with_options`. At most one time-travel selector
+may be set. A selector that does not resolve to a snapshot is an error; it
never
+silently falls back to the latest snapshot.
+
+Supported selectors:
+
+- `scan.snapshot-id`
+- `scan.tag-name`
+- `scan.timestamp-millis`
+- `scan.timestamp`
+- `scan.watermark`
+- `scan.version`
+
+```c
+paimon_option travel[] = {
+ {.key = "scan.snapshot-id", .value = "1"},
+};
+paimon_result_read_builder builder_result =
+ paimon_table_new_read_builder_with_options(table, travel, 1);
+CHECK_RESULT(builder_result);
+read_builder = builder_result.read_builder;
+```
+
+`paimon_table_new_read_builder(table)` is equivalent to calling the options
+variant with an empty option list.
+
+### Tag Management
+
+Catalog tags pin table snapshots:
+
+```c
+/* Tag the latest snapshot. Pass a non-null i64* to pin an explicit snapshot.
*/
+paimon_error *error =
+ paimon_catalog_create_tag(catalog, identifier, "release-1.0", NULL, false);
+if (error != NULL) {
+ /* handle error */
+ paimon_error_free(error);
+}
+
+paimon_result_get_tag tag_result =
+ paimon_catalog_get_tag(catalog, identifier, "release-1.0");
+if (tag_result.error != NULL) {
+ /* handle error */
+ paimon_error_free(tag_result.error);
+} else {
+ /* tag_result.tag holds JSON bytes owned by the caller */
+ paimon_bytes_free(tag_result.tag);
+}
+
+error = paimon_catalog_delete_tag(catalog, identifier, "release-1.0");
+if (error != NULL) {
+ paimon_error_free(error);
+}
+```
+
+`ignore_if_exists` on create ignores a duplicate tag name. Delete does not
+ignore a missing tag. The C binding does not expose tag listing; read a known
+tag with `paimon_catalog_get_tag`, or use time travel with `scan.tag-name`.
+
+`paimon_catalog_create_tag` keeps the no-retention path by calling
+`paimon_catalog_create_tag_with_retention` with a null `time_retained`. Pass a
+duration such as `"1d"` or `"12h"` to persist retention on the tag file; this
+does not expire or delete tags automatically:
+
+```c
+/* Optional retention. NULL time_retained omits retention metadata. */
+error = paimon_catalog_create_tag_with_retention(
+ catalog, identifier, "release-retained", NULL, "1d", false);
+if (error != NULL) {
+ paimon_error_free(error);
+}
+```
+
+`paimon_catalog_get_tag` JSON may include `tagTimeRetained` as an ISO-8601
+duration (for example `"1d"` becomes `"PT24H"`).
+
## Caller-managed File Cache
Native engines can create a reusable `paimon_file_io` and connect Paimon reads
diff --git a/docs/src/python-binding.md b/docs/src/python-binding.md
index 0098ccab..e5feac24 100644
--- a/docs/src/python-binding.md
+++ b/docs/src/python-binding.md
@@ -94,6 +94,32 @@ for batch in batches:
print(batch)
```
+### Streaming SQL results
+
+`sql_stream()` executes one SQL query and returns a `RecordBatchReader`,
yielding
+PyArrow batches without collecting the entire result in memory. Close the
reader
+when stopping early to release the execution stream:
+
+```python
+from contextlib import closing
+
+with closing(ctx.sql_stream("SELECT id, name FROM paimon.my_db.t")) as reader:
+ for batch in reader:
+ print(batch.to_pydict())
+```
+
+`read_next_batch()` returns `None` when the reader is exhausted or closed.
+`reader.schema` is known before the first batch, so
+`pa.Table.from_batches(reader, schema=reader.schema)` also handles an empty
+result. Statements that write, such as `INSERT`, finish before `sql_stream()`
+returns. Errors during execution can surface while reading a batch and end the
+stream.
+
+`sql_stream_with_options(sql, options)` applies `SQLOptions` as
+`sql_with_options()` does: they restrict statements delegated to DataFusion,
but
+not statements Paimon handles itself, such as `DELETE`, `UPDATE`, or `DROP
TABLE`
+on a Paimon table.
+
### Runtime Resource Configuration
`SQLContext` can use a bounded DataFusion memory pool and a dedicated temporary
@@ -510,6 +536,9 @@ rb = table.new_read_builder({"scan.version": "3"})
# By tag name
rb = table.new_read_builder({"scan.tag-name": "release-1.0"})
+
+# By watermark
+rb = table.new_read_builder({"scan.watermark": "1700000000000"})
```
!!! warning
@@ -549,7 +578,7 @@ if snap:
for snap in table.list_snapshots():
print(snap.id(), snap.commit_kind())
-# Tags
+# Tags pinned on this table/branch
for tag in table.list_tags():
print(tag.name(), tag.snapshot_id())
@@ -558,6 +587,110 @@ for stat in table.partition_stats():
print(stat.partition(), stat.record_count(), stat.total_size_bytes())
```
+### Tag Management
+
+`table.list_tags()` only inspects tags. Create, fetch, page, delete, and
rollback
+go through the catalog. The Python binding exposes one API surface for every
+catalog, but support depends on the catalog implementation.
+
+Filesystem Catalog supports creating, fetching, and deleting tags. It does not
+implement `list_tags_paged` or `rollback_to`.
+
+```python
+identifier = ("my_db", "users")
+
+# Pin the latest snapshot, or pass snapshot_id=... for an explicit snapshot.
+catalog.create_tag(identifier, "release-1.0")
+tag = catalog.get_tag(identifier, "release-1.0")
+print(tag.tag_name(), tag.snapshot().id())
+
+catalog.delete_tag(identifier, "release-1.0")
+```
+
+`create_tag(..., time_retained=...)` accepts an optional retention duration on
+both Filesystem Catalog and REST Catalog. `ignore_if_exists=True` ignores a
+duplicate tag name.
+
+REST Catalog also supports paged listing and rollback. These require
+`metastore: rest` and a running Paimon REST Server (see
+[REST Catalog](#rest-catalog) above). Finish every operation that needs the tag
+before deleting it:
+
+```python
+from pypaimon_rust.datafusion import Instant, PaimonCatalog
+
+catalog = PaimonCatalog({
+ "metastore": "rest",
+ "uri": "http://localhost:8080",
+ "warehouse": "my_warehouse",
+})
+identifier = ("my_db", "users")
+
+catalog.create_tag(identifier, "release-1.0", snapshot_id=1)
+names, next_token = catalog.list_tags_paged(identifier, max_results=100)
+
+# Pick one rollback target. Rolling back to an earlier snapshot deletes tags
+# that point at newer snapshots.
+catalog.rollback_to(identifier, Instant.tag("release-1.0"))
+# Or: catalog.rollback_to(identifier, Instant.snapshot(1))
+
+catalog.delete_tag(identifier, "release-1.0")
+```
+
+## Native Search
+
+Tables with vector or full-text indexes can search through the Rust core
without
+materializing candidate rows in Python first:
+
+```python
+# Scalar vector search
+search = (
+ table.new_vector_search_builder()
+ .with_vector_column("embedding")
+ .with_query_vector([1.0, 0.0])
+ .with_limit(10)
+)
+plan = search.new_vector_search_scan().scan()
+result = search.new_vector_search_read().read_plan(plan)
+batches = result.new_read_builder().with_projection(["id"]).read()
+
+# Batch vector search returns one GlobalIndexResult per input query, in order
+batch = (
+ table.new_batch_vector_search_builder()
+ .with_vector_column("embedding")
+ .with_query_vectors([[1.0, 0.0], [0.0, 1.0]])
+ .with_limit(5)
+)
+results = batch.execute()
+
+# Full-text search — query is a serialized match DSL, not plain text
+text = (
+ table.new_full_text_search_builder()
+ .with_query("body", '{"match":{"query":"needle"}}')
+ .with_limit(10)
+)
+text_result = text.execute()
+
+# Hybrid vector + full-text search
+hybrid = (
+ table.new_hybrid_search_builder()
+ .add_vector_route("embedding", [1.0, 0.0], 10)
+ .add_full_text_route("body", '{"match":{"query":"needle"}}', 10)
+ .with_limit(5)
+)
+ranked = hybrid.execute()
+```
+
+`with_query` and `add_full_text_route` take a JSON DSL string (for example
+`{"match":{"query":"..."}}`), not a bare search term. Plain text raises a JSON
+parse error.
+
+`execute()` returns a `GlobalIndexResult` (or a list of them for batch vector
+search). Reusable scan/read plans pin one snapshot; scalar and partition
filters
+are applied before ranking. Projected reads can include `__paimon_search_score`
+in relevance order. Hybrid routes can also be configured and executed
separately
+through `route_builders()` / `rank(...)`.
+
## Table Maintenance
### Compaction
@@ -594,6 +727,47 @@ the catalog options; without it `execute()` raises
`ValueError` once there are
tasks to run. See [Table Compaction](compaction.md) for the supported table
modes.
+### Global Index Build and Drop
+
+Build or drop global indexes with dedicated builders. Defaults use index type
+`btree`. `execute()` plans and commits in one call. `build()` and
+`build_shard()` return commit messages for the caller to publish.
+`plan()` exposes shards for distributed builds.
+
+```python
+# One-shot build and commit
+built = (
+ table.new_global_index_build_builder()
+ .with_index_column("embedding")
+ .with_index_type("ivf-flat")
+ .with_options({"dimension": "2", "nlist": "1", "metric": "l2"})
+ .execute()
+)
+
+# Advanced: build() returns commit messages for an explicit commit
+messages = (
+ table.new_global_index_build_builder()
+ .with_index_columns(["name"])
+ .with_index_type("btree")
+ .with_partition_filter({"method": "equal", "field": "dt", "literals":
["2026-11-01"]})
+ .build()
+)
+table.new_batch_write_builder().new_commit().commit(messages)
+
+# Drop indexes; dry_run=True reports work without committing
+dropped = (
+ table.new_global_index_drop_builder()
+ .with_index_column("name")
+ .with_index_type("btree")
+ .with_dry_run(False)
+ .execute()
+)
+```
+
+`GlobalIndexBuildBuilder.supports_index_type(...)` and
+`GlobalIndexDropBuilder.supports_index_type(...)` report which index types the
+builders accept.
+
## Python UDF
Register Python scalar UDFs into a `SQLContext`: