diff --git a/docs/cn/sql-reference/10-sql-commands/00-ddl/21-table-versioning/index.md b/docs/cn/sql-reference/10-sql-commands/00-ddl/21-table-versioning/index.md index 41dfdb4693..030b0428e2 100644 --- a/docs/cn/sql-reference/10-sql-commands/00-ddl/21-table-versioning/index.md +++ b/docs/cn/sql-reference/10-sql-commands/00-ddl/21-table-versioning/index.md @@ -39,3 +39,4 @@ SET enable_experimental_table_ref = 1; |------|------| | [CREATE SNAPSHOT TAG](01-create-snapshot-tag.md) | 在表快照上创建命名标签 | | [DROP SNAPSHOT TAG](02-drop-snapshot-tag.md) | 删除快照标签 | +| [FUSE_TAG](../../../20-sql-functions/16-system-functions/fuse_tag.md) | 列出表上所有快照标签 | diff --git a/docs/cn/sql-reference/20-sql-functions/16-system-functions/fuse_tag.md b/docs/cn/sql-reference/20-sql-functions/16-system-functions/fuse_tag.md new file mode 100644 index 0000000000..b1af39e35b --- /dev/null +++ b/docs/cn/sql-reference/20-sql-functions/16-system-functions/fuse_tag.md @@ -0,0 +1,53 @@ +--- +title: FUSE_TAG +--- + +import FunctionDescription from '@site/src/components/FunctionDescription'; + + + +import EEFeature from '@site/src/components/EEFeature'; + + + +返回表的快照标签信息。有关快照标签的更多信息,请参阅[快照标签](../../10-sql-commands/00-ddl/21-table-versioning/index.md#snapshot-tags)。 + +## 语法 + +```sql +FUSE_TAG('<数据库名称>', '<表名称>') +``` + +## 输出列 + +| 列名 | 类型 | 描述 | +|---------------------|--------------------|----------------------------------------------------------------------------| +| name | STRING | 标签名称 | +| snapshot_location | STRING | 标签指向的快照文件 | +| expire_at | TIMESTAMP (可为空) | 过期时间戳;在 CREATE SNAPSHOT TAG 中使用 `RETAIN` 时设置 | + +## 示例 + +```sql +SET enable_experimental_table_ref = 1; + +CREATE TABLE mytable(a INT, b INT); + +INSERT INTO mytable VALUES(1, 1),(2, 2); + +-- 创建快照标签 +ALTER TABLE mytable CREATE TAG v1; + +INSERT INTO mytable VALUES(3, 3); + +-- 创建带过期时间的标签 +ALTER TABLE mytable CREATE TAG temp RETAIN 2 DAYS; + +SELECT * FROM FUSE_TAG('default', 'mytable'); + +--- +| name | snapshot_location | expire_at | +|------|------------------------------------------------------------|----------------------------| +| v1 | 1/319/_ss/a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4_v4.mpk | NULL | +| temp | 1/319/_ss/f6e5d4c3b2a1f6e5d4c3b2a1f6e5d4c3_v4.mpk | 2025-06-15 10:30:00.000000 | +``` diff --git a/docs/cn/sql-reference/20-sql-functions/16-system-functions/index.md b/docs/cn/sql-reference/20-sql-functions/16-system-functions/index.md index df596a19b8..45cb79fab5 100644 --- a/docs/cn/sql-reference/20-sql-functions/16-system-functions/index.md +++ b/docs/cn/sql-reference/20-sql-functions/16-system-functions/index.md @@ -18,6 +18,7 @@ title: 系统函数 (System Functions) | [FUSE_SEGMENT](fuse_segment.md) | 返回表的段信息 | `FUSE_SEGMENT('default', 'mytable')` | | [FUSE_BLOCK](fuse_block.md) | 返回表的块信息 | `FUSE_BLOCK('default', 'mytable')` | | [FUSE_COLUMN](fuse_column.md) | 返回表的列信息 | `FUSE_COLUMN('default', 'mytable')` | +| [FUSE_TAG](fuse_tag.md) | 返回表的快照标签信息 | `FUSE_TAG('default', 'mytable')` | ## 存储优化函数 diff --git a/docs/en/sql-reference/10-sql-commands/00-ddl/21-table-versioning/index.md b/docs/en/sql-reference/10-sql-commands/00-ddl/21-table-versioning/index.md index e6a69a9ed1..2ec2dc1f27 100644 --- a/docs/en/sql-reference/10-sql-commands/00-ddl/21-table-versioning/index.md +++ b/docs/en/sql-reference/10-sql-commands/00-ddl/21-table-versioning/index.md @@ -39,3 +39,4 @@ A snapshot tag attaches a human-readable name to a snapshot. As long as the tag |---------|-------------| | [CREATE SNAPSHOT TAG](01-create-snapshot-tag.md) | Create a named tag on a table snapshot | | [DROP SNAPSHOT TAG](02-drop-snapshot-tag.md) | Remove a snapshot tag | +| [FUSE_TAG](../../../20-sql-functions/16-system-functions/fuse_tag.md) | List all snapshot tags on a table | diff --git a/docs/en/sql-reference/20-sql-functions/16-system-functions/fuse_tag.md b/docs/en/sql-reference/20-sql-functions/16-system-functions/fuse_tag.md new file mode 100644 index 0000000000..7f5cff1ac3 --- /dev/null +++ b/docs/en/sql-reference/20-sql-functions/16-system-functions/fuse_tag.md @@ -0,0 +1,53 @@ +--- +title: FUSE_TAG +--- + +import FunctionDescription from '@site/src/components/FunctionDescription'; + + + +import EEFeature from '@site/src/components/EEFeature'; + + + +Returns the snapshot tags of a table. For more information about snapshot tags, see [Snapshot Tags](../../10-sql-commands/00-ddl/21-table-versioning/index.md#snapshot-tags). + +## Syntax + +```sql +FUSE_TAG('', '') +``` + +## Output Columns + +| Column | Type | Description | +|---------------------|--------------------|-----------------------------------------------------------------------------| +| name | STRING | Tag name | +| snapshot_location | STRING | Snapshot file the tag points to | +| expire_at | TIMESTAMP (nullable) | Expiration timestamp; set when `RETAIN` is used in CREATE SNAPSHOT TAG | + +## Examples + +```sql +SET enable_experimental_table_ref = 1; + +CREATE TABLE mytable(a INT, b INT); + +INSERT INTO mytable VALUES(1, 1),(2, 2); + +-- Create a snapshot tag +ALTER TABLE mytable CREATE TAG v1; + +INSERT INTO mytable VALUES(3, 3); + +-- Create another tag with expiration +ALTER TABLE mytable CREATE TAG temp RETAIN 2 DAYS; + +SELECT * FROM FUSE_TAG('default', 'mytable'); + +--- +| name | snapshot_location | expire_at | +|------|------------------------------------------------------------|----------------------------| +| v1 | 1/319/_ss/a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4_v4.mpk | NULL | +| temp | 1/319/_ss/f6e5d4c3b2a1f6e5d4c3b2a1f6e5d4c3_v4.mpk | 2025-06-15 10:30:00.000000 | +``` diff --git a/docs/en/sql-reference/20-sql-functions/16-system-functions/index.md b/docs/en/sql-reference/20-sql-functions/16-system-functions/index.md index c270b94650..a7b2f62564 100644 --- a/docs/en/sql-reference/20-sql-functions/16-system-functions/index.md +++ b/docs/en/sql-reference/20-sql-functions/16-system-functions/index.md @@ -18,6 +18,7 @@ This page provides reference information for the system-related functions in Dat | [FUSE_SEGMENT](fuse_segment.md) | Returns segment information of a table | `FUSE_SEGMENT('default', 'mytable')` | | [FUSE_BLOCK](fuse_block.md) | Returns block information of a table | `FUSE_BLOCK('default', 'mytable')` | | [FUSE_COLUMN](fuse_column.md) | Returns column information of a table | `FUSE_COLUMN('default', 'mytable')` | +| [FUSE_TAG](fuse_tag.md) | Returns snapshot tag information of a table | `FUSE_TAG('default', 'mytable')` | ## Storage Optimization Functions