VeloDB Cloud
SQL Manual
SQL Functions
Table Valued Functions
PARTITIONS

partitions

Name

partitions

Description

The table function generates a temporary partition TABLE, which allows you to view the PARTITION list of a certain TABLE.

This function is used in the from clause.

Syntax

partitions("catalog"="","database"="","table"="")

partitions() Table structure:

mysql> desc function partitions("catalog"="internal","database"="zd","table"="user");
+--------------------------+---------+------+-------+---------+-------+
| Field                    | Type    | Null | Key   | Default | Extra |
+--------------------------+---------+------+-------+---------+-------+
| PartitionId              | BIGINT  | No   | false | NULL    | NONE  |
| PartitionName            | TEXT    | No   | false | NULL    | NONE  |
| VisibleVersion           | BIGINT  | No   | false | NULL    | NONE  |
| VisibleVersionTime       | TEXT    | No   | false | NULL    | NONE  |
| State                    | TEXT    | No   | false | NULL    | NONE  |
| PartitionKey             | TEXT    | No   | false | NULL    | NONE  |
| Range                    | TEXT    | No   | false | NULL    | NONE  |
| DistributionKey          | TEXT    | No   | false | NULL    | NONE  |
| Buckets                  | INT     | No   | false | NULL    | NONE  |
| ReplicationNum           | INT     | No   | false | NULL    | NONE  |
| StorageMedium            | TEXT    | No   | false | NULL    | NONE  |
| CooldownTime             | TEXT    | No   | false | NULL    | NONE  |
| RemoteStoragePolicy      | TEXT    | No   | false | NULL    | NONE  |
| LastConsistencyCheckTime | TEXT    | No   | false | NULL    | NONE  |
| DataSize                 | TEXT    | No   | false | NULL    | NONE  |
| IsInMemory               | BOOLEAN | No   | false | NULL    | NONE  |
| ReplicaAllocation        | TEXT    | No   | false | NULL    | NONE  |
| IsMutable                | BOOLEAN | No   | false | NULL    | NONE  |
| SyncWithBaseTables       | BOOLEAN | No   | false | NULL    | NONE  |
| UnsyncTables             | TEXT    | No   | false | NULL    | NONE  |
+--------------------------+---------+------+-------+---------+-------+
20 rows in set (0.02 sec)
  • PartitionId:partition id
  • PartitionName:partition name
  • VisibleVersion:visible version
  • VisibleVersionTime:visible version time
  • State:state
  • PartitionKey:partition key
  • Range:range
  • DistributionKey:distribution key
  • Buckets:bucket num
  • ReplicationNum:replication num
  • StorageMedium:storage medium
  • CooldownTime:cooldown time
  • RemoteStoragePolicy:remote storage policy
  • LastConsistencyCheckTime:last consistency check time
  • DataSize:data size
  • IsInMemory:is in memory
  • ReplicaAllocation:replica allocation
  • IsMutable:is mutable
  • SyncWithBaseTables:Is it synchronized with the base table data (for partitioning asynchronous materialized views)
  • UnsyncTables:Which base table data is not synchronized with (for partitions of asynchronous materialized views)
mysql> desc function partitions("catalog"="hive","database"="zdtest","table"="com2");
+-----------+------+------+-------+---------+-------+
| Field     | Type | Null | Key   | Default | Extra |
+-----------+------+------+-------+---------+-------+
| Partition | TEXT | No   | false | NULL    | NONE  |
+-----------+------+------+-------+---------+-------+
1 row in set (0.11 sec)
  • Partition:partition name

Example

  1. View the partition list of table1 under db1 in the internal catalog
mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1");
  1. View the partition information with partition name partition1 under table1
mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1";
  1. View the partition ID with the partition name 'partition1' under Table 1
mysql> select PartitionId from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1";

Keywords

partitions