This documentation is for an unreleased version of Apache Paimon. We recommend you use the latest stable version.
Manage Tags
Manage Tags #
Just like Java API of Paimon, you can create a tag based on a snapshot. The tag will maintain the manifests and data files of the snapshot. A typical usage is creating tags daily, then you can maintain the historical data of each day for batch reading.
Create and Delete Tag #
You can create a tag with given name and snapshot ID, and delete a tag with given name.
table = catalog.get_table('database_name.table_name')
table.create_tag("tag2", snapshot_id=2) # create tag2 based on snapshot 2
table.create_tag("tag2") # create tag2 based on latest snapshot
table.delete_tag("tag2") # delete tag2
If snapshot_id unset, snapshot_id defaults to the latest.
Read Tag #
You can read data from a specific tag.
table = catalog.get_table('database_name.table_name')
table.create_tag("tag2", snapshot_id=2)
# Read from tag2 using scan.tag-name option
table_with_tag = table.copy({"scan.tag-name": "tag2"})
read_builder = table_with_tag.new_read_builder()
table_scan = read_builder.new_scan()
table_read = read_builder.new_read()
result = table_read.to_arrow(table_scan.plan().splits())