partitions

Name

partitions

Description

表函数,生成分区临时表,可以查看某个 TABLE 的分区列表。

该函数用于 From 子句中。

该函数自 2.1.5 版本开始支持。

Syntax

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

partitions()表结构:

  1. mysql> desc function partitions("catalog"="internal","database"="zd","table"="user");
  2. +--------------------------+---------+------+-------+---------+-------+
  3. | Field | Type | Null | Key | Default | Extra |
  4. +--------------------------+---------+------+-------+---------+-------+
  5. | PartitionId | BIGINT | No | false | NULL | NONE |
  6. | PartitionName | TEXT | No | false | NULL | NONE |
  7. | VisibleVersion | BIGINT | No | false | NULL | NONE |
  8. | VisibleVersionTime | TEXT | No | false | NULL | NONE |
  9. | State | TEXT | No | false | NULL | NONE |
  10. | PartitionKey | TEXT | No | false | NULL | NONE |
  11. | Range | TEXT | No | false | NULL | NONE |
  12. | DistributionKey | TEXT | No | false | NULL | NONE |
  13. | Buckets | INT | No | false | NULL | NONE |
  14. | ReplicationNum | INT | No | false | NULL | NONE |
  15. | StorageMedium | TEXT | No | false | NULL | NONE |
  16. | CooldownTime | TEXT | No | false | NULL | NONE |
  17. | RemoteStoragePolicy | TEXT | No | false | NULL | NONE |
  18. | LastConsistencyCheckTime | TEXT | No | false | NULL | NONE |
  19. | DataSize | TEXT | No | false | NULL | NONE |
  20. | IsInMemory | BOOLEAN | No | false | NULL | NONE |
  21. | ReplicaAllocation | TEXT | No | false | NULL | NONE |
  22. | IsMutable | BOOLEAN | No | false | NULL | NONE |
  23. | SyncWithBaseTables | BOOLEAN | No | false | NULL | NONE |
  24. | UnsyncTables | TEXT | No | false | NULL | NONE |
  25. +--------------------------+---------+------+-------+---------+-------+
  26. 20 rows in set (0.02 sec)
  • PartitionId:分区id
  • PartitionName:分区名字
  • VisibleVersion:分区版本
  • VisibleVersionTime:分区版本提交时间
  • State:分区状态
  • PartitionKey:分区key
  • Range:分区范围
  • DistributionKey:分布key
  • Buckets:分桶数量
  • ReplicationNum:副本数
  • StorageMedium:存储介质
  • CooldownTime:cooldown时间
  • RemoteStoragePolicy:远程存储策略
  • LastConsistencyCheckTime:上次一致性检查时间
  • DataSize:数据大小
  • IsInMemory:是否存在内存
  • ReplicaAllocation:分布策略
  • IsMutable:是否可变
  • SyncWithBaseTables:是否和基表数据同步(针对异步物化视图的分区)
  • UnsyncTables:和哪个基表数据不同步(针对异步物化视图的分区)
  1. mysql> desc function partitions("catalog"="hive","database"="zdtest","table"="com2");
  2. +-----------+------+------+-------+---------+-------+
  3. | Field | Type | Null | Key | Default | Extra |
  4. +-----------+------+------+-------+---------+-------+
  5. | Partition | TEXT | No | false | NULL | NONE |
  6. +-----------+------+------+-------+---------+-------+
  7. 1 row in set (0.11 sec)
  • Partition:分区名字

Example

  1. 查看 internal CATALOG 下 db1 的 table1 的分区列表
  1. mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1");
  1. 查看 table1 下的分区名称为 partition1 的分区信息
  1. mysql> select * from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1";
  1. 查看 table1 下的分区名称为 partition1 的分区 id
  1. mysql> select PartitionId from partitions("catalog"="internal","database"="db1","table"="table1") where PartitionName = "partition1";

Keywords

  1. partitions