Skip to content

Commit 96b0f55

Browse files
authored
Merge pull request #7521 from soyeric128/system-functions
docs: system functions
2 parents 165458d + b96b933 commit 96b0f55

File tree

5 files changed

+106
-7
lines changed

5 files changed

+106
-7
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"label": "System Functions",
3+
"link": {
4+
"type": "generated-index",
5+
"slug": "/reference/functions/system-functions"
6+
}
7+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: CLUSTERING_INFORMATION
3+
---
4+
5+
Returns clustering information of a table.
6+
7+
## Syntax
8+
9+
```sql
10+
CLUSTERING_INFORMATION(‘<database_name>’, ‘<table_name>’)
11+
```
12+
13+
## Examples
14+
15+
```sql
16+
CREATE TABLE mytable(a int, b int) CLUSTER BY(a+1);
17+
18+
INSERT INTO mytable VALUES(1,1),(3,3);
19+
INSERT INTO mytable VALUES(2,2),(5,5);
20+
INSERT INTO mytable VALUES(4,4);
21+
22+
SELECT * FROM CLUSTERING_INFORMATION(‘default‘,’mytable‘);
23+
24+
---
25+
| cluster_by_keys | total_block_count | total_constant_block_count | average_overlaps | average_depth | block_depth_histogram |
26+
|-----------------|-------------------|----------------------------|------------------|---------------|-----------------------|
27+
| ((a + 1)) | 3 | 1 | 1.3333 | 2.0 | {"00002":3} |
28+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: FUSE_SEGMENT
3+
---
4+
5+
Returns the segment information of a snapshot of table.
6+
7+
## Syntax
8+
9+
```sql
10+
FUSE_SEGMENT('<database_name>', '<table_name>','<snapshot_id>')
11+
```
12+
13+
## Examples
14+
15+
```sql
16+
CREATE TABLE mytable(c int);
17+
INSERT INTO mytable values(1);
18+
INSERT INTO mytable values(2);
19+
20+
-- Obtain a snapshot ID
21+
SELECT snapshot_id FROM FUSE_SNAPSHOT('default', 'mytable') limit 1;
22+
23+
---
24+
+----------------------------------+
25+
| snapshot_id |
26+
+----------------------------------+
27+
| 82c572947efa476892bd7c0635158ba2 |
28+
+----------------------------------+
29+
30+
SELECT * FROM FUSE_SEGMENT('default', 'mytable', '82c572947efa476892bd7c0635158ba2');
31+
32+
---
33+
+----------------------------------------------------+----------------+-------------+-----------+--------------------+------------------+
34+
| file_location | format_version | block_count | row_count | bytes_uncompressed | bytes_compressed |
35+
+----------------------------------------------------+----------------+-------------+-----------+--------------------+------------------+
36+
| 1/319/_sg/d35fe7bf99584301b22e8f6a8a9c97f9_v1.json | 1 | 1 | 1 | 4 | 184 |
37+
| 1/319/_sg/c261059d47c840e1b749222dabb4b2bb_v1.json | 1 | 1 | 1 | 4 | 184 |
38+
+----------------------------------------------------+----------------+-------------+-----------+--------------------+------------------+
39+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: FUSE_SNAPSHOT
3+
---
4+
5+
Returns the snapshot information of a table for querying previous versions of your data. For more information, see [AT](../../30-sql/20-query-syntax/dml-at.md).
6+
7+
## Syntax
8+
9+
```sql
10+
FUSE_SNAPSHOT('<database_name>', '<table_name>')
11+
```
12+
13+
## Examples
14+
15+
```sql
16+
CREATE TABLE mytable(a int, b int) CLUSTER BY(a+1);
17+
18+
INSERT INTO mytable VALUES(1,1),(3,3);
19+
INSERT INTO mytable VALUES(2,2),(5,5);
20+
INSERT INTO mytable VALUES(4,4);
21+
22+
SELECT * FROM FUSE_SNAPSHOT(‘default‘,’mytable‘);
23+
24+
---
25+
| snapshot_id | snapshot_location | format_version | previous_snapshot_id | segment_count | block_count | row_count | bytes_uncompressed | bytes_compressed | timestamp |
26+
|----------------------------------|------------------------------------------------------------|----------------|----------------------------------|---------------|-------------|-----------|--------------------|------------------|----------------------------|
27+
| dd98266f968f4817b470255592d04fda | 670655/670675/_ss/dd98266f968f4817b470255592d04fda_v1.json | 1 | \N | 1 | 1 | 2 | 16 | 290 | 2022-09-07 01:58:55.204997 |
28+
| 2f2d004ff6f842cdb25f5631b2bbb703 | 670655/670675/_ss/2f2d004ff6f842cdb25f5631b2bbb703_v1.json | 1 | dd98266f968f4817b470255592d04fda | 2 | 2 | 4 | 32 | 580 | 2022-09-07 01:59:09.742999 |
29+
| 0aa6dfd5d5364bde80f21161ba48c96e | 670655/670675/_ss/0aa6dfd5d5364bde80f21161ba48c96e_v1.json | 1 | 2f2d004ff6f842cdb25f5631b2bbb703 | 3 | 3 | 5 | 40 | 862 | 2022-09-07 01:59:16.858454 |
30+
```

docs/doc/30-reference/30-sql/20-query-syntax/dml-at.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: AT
33
---
44

5-
The SELECT statement can include an AT clause that allows you to query previous versions of your data by a specific snapshot ID or timestamp.
5+
The SELECT statement can include an AT clause that allows you to query previous versions of your data by a specific snapshot ID or timestamp.
66

77
Databend automatically creates snapshots when data updates occur, so a snapshot can be considered as a view of your data at a time point in the past. You can access a snapshot by the snapshot ID or the timestamp at which the snapshot was created. For how to obtain the snapshot ID and timestamp, see [Obtaining Snapshot ID and Timestamp](#obtaining-snapshot-id-and-timestamp).
88

@@ -26,12 +26,7 @@ SELECT snapshot_id,
2626
FROM fuse_snapshot('<database_name>', '<table_name>');
2727
```
2828

29-
You can find more information related to the snapshots by executing the following statement:
30-
31-
```sql
32-
SELECT *
33-
FROM Fuse_snapshot('<database_name>', '<table_name>');
34-
```
29+
For more information about the FUSE_SNAPSHOT function,see [FUSE_SNAPSHOT](../../20-functions/111-system-functions/fuse_snapshot.md).
3530

3631
## Examples
3732

0 commit comments

Comments
 (0)