Skip to content

feat(datafusion): support create_tag_from_watermark - #1134

Open
QuakeWang wants to merge 2 commits into
apache:mainfrom
QuakeWang:watermark-tag
Open

QuakeWang wants to merge 2 commits into
apache:mainfrom
QuakeWang:watermark-tag

Conversation

@QuakeWang

Copy link
Copy Markdown
Member

Purpose

SQL can create tags by commit time but cannot pin a version by watermark without manually resolving a snapshot ID.

Brief change log

Add sys.create_tag_from_watermark with live and tag-retained snapshot selection, earlier snapshot IDs for equal watermarks, optional retention, and validation before writing.

Tests

  • 58 procedure tests passed, including 7 new watermark cases.
  • Rust 1.98.0 formatting and full workspace Clippy passed.

API and Format

Adds a SQL procedure and reuses the existing tag format.

Documentation

Documents watermark semantics and usage; corrects timestamp selection wording.

Add a SQL entry point for watermark-based tags, including snapshots retained
by existing tags and optional retention. Preserve existing tags on errors.

Cover candidate selection and validation through SQL integration tests, and
document watermark semantics.

Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requirement fit: SUPPORTED. Implementation: FINDINGS at 5175997. Pinning a readable version by ingestion watermark has end-to-end value, and the live/tag selection matches the Java reference for nondecreasing watermarks.

Validation: all 58 SQL procedure tests, 18 snapshot-manager tests, and 16 tag-manager tests passed. Rust 1.98.0 formatting passed, and integration with main 7dd674b is conflict-free. An additional independent SQL/HTTP probe used actual SQL-written Parquet and demonstrated the REST-catalog compatibility gap below: SELECT reads the catalog-only latest snapshot, while this new procedure reports that no qualifying snapshot exists. No tag was written by the failing call.

"Tag '{tag_name}' already exists"
)));
}
let snapshot = later_or_equal_watermark_from_all(&sm, &tm, watermark)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Resolve watermark candidates from authoritative REST metadata

This new entry point accepts REST tables, but managers(&table) creates a filesystem-only SnapshotManager, and later_or_equal_watermark enumerates only physical snapshot files. REST snapshots can legitimately exist only in the catalog: RESTSnapshotCommit::commit sends the snapshot over HTTP without publishing a snapshot file. I reproduced this with two real SQL-written Parquet snapshots (watermarks 1000/2000), retained snapshot-1 on storage, and snapshot-2 served only by the REST catalog. SELECT id FROM paimon.test_db.t1 ORDER BY id returns both rows, but CALL sys.create_tag_from_watermark(table => 'test_db.t1', tag => 'checkpoint', watermark => 2000) fails with No snapshot found with watermark >= 2000; the call makes no /snapshot request. Thus a readable REST table cannot use the advertised checkpoint operation. Please resolve candidates through the catalog-aware metadata path, or explicitly reject/document unsupported REST tables before selection, with this SQL/HTTP regression. Merely switching the helper to table.snapshot_manager() is insufficient because its watermark search still lists storage files.

Reject REST-managed tables before filesystem candidate selection because
their authoritative snapshots may exist only in the catalog.

Add a SQL/HTTP regression with real Parquet data and a catalog-only latest
snapshot, and document this limitation.

Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants