|
| 1 | +--- |
| 2 | +title: FUSE_TIME_TRAVEL_SIZE |
| 3 | +--- |
| 4 | +import FunctionDescription from '@site/src/components/FunctionDescription'; |
| 5 | + |
| 6 | +<FunctionDescription description="Introduced or updated: v1.2.684"/> |
| 7 | + |
| 8 | +Calculates the storage size of historical data (for Time Travel) for tables. |
| 9 | + |
| 10 | +## Syntax |
| 11 | + |
| 12 | +```sql |
| 13 | +-- Calculate historical data size for all tables in all databases |
| 14 | +SELECT ... |
| 15 | +FROM fuse_time_travel_size(); |
| 16 | + |
| 17 | +-- Calculate historical data size for all tables in a specified database |
| 18 | +SELECT ... |
| 19 | +FROM fuse_time_travel_size('<database_name>'); |
| 20 | + |
| 21 | +-- Calculate historical data size for a specified table in a specified database |
| 22 | +SELECT ... |
| 23 | +FROM fuse_time_travel_size('<database_name>', '<table_name>')); |
| 24 | +``` |
| 25 | + |
| 26 | +## Output |
| 27 | + |
| 28 | +The function returns a result set with the following columns: |
| 29 | + |
| 30 | +| Column | Description | |
| 31 | +|----------------------------------|-------------------------------------------------------------------------------------------------------| |
| 32 | +| `database_name` | The name of the database where the table is located. | |
| 33 | +| `table_name` | The name of the table. | |
| 34 | +| `is_dropped` | Indicates whether the table has been dropped (`true` for dropped tables, `false` otherwise). | |
| 35 | +| `time_travel_size` | The total storage size of historical data (for Time Travel) for the table, in bytes. | |
| 36 | +| `latest_snapshot_size` | The storage size of the latest snapshot of the table, in bytes. | |
| 37 | +| `data_retention_period_in_hours` | The retention period for Time Travel data in hours (`NULL` means using the default retention policy). | |
| 38 | +| `error` | Any error encountered while retrieving the storage size (`NULL` if no errors occurred). | |
| 39 | + |
| 40 | +## Examples |
| 41 | + |
| 42 | +This example calculates the historical data for all tables in the `default` database: |
| 43 | + |
| 44 | +```sql |
| 45 | +SELECT * FROM fuse_time_travel_size('default') |
| 46 | + |
| 47 | +┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ |
| 48 | +│ database_name │ table_name │ is_dropped │ time_travel_size │ latest_snapshot_size │ data_retention_period_in_hours │ error │ |
| 49 | +├───────────────┼────────────┼────────────┼──────────────────┼──────────────────────┼────────────────────────────────┼──────────────────┤ |
| 50 | +│ default │ books │ true │ 2810 │ 1490 │ NULL │ NULL │ |
| 51 | +└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ |
| 52 | +``` |
0 commit comments