分区
更新时间:2024-12-13
分区管理
PartitionInstance结构体
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
values | List<String> | 是 | 分区值 |
location | String | 否 | 分区位置绝对路径 |
createTime | String | 否 | 创建时间 |
properties | Map<String, String> | 否 | 自定义附加参数 |
authProperties | Map<String, String> | 否 | 安全认证信息 |
ListPartitions
接口说明
获取表分区列表信息
请求原型
Plain Text
1GET /v1/database/${databaseName}/table/${tableName}/partition
请求参数
字段 | 类型 | 位置 | 是否必须 | 描述 |
---|---|---|---|---|
databaseName | String | URL | 是 | 数据库名 |
tableName | String | URL | 是 | 表名 |
pageNo | Integer | QueryString | 是 | 页码 |
pageSize | Integer | QueryString | 是 | 每页查询记录数 |
filter | String | QueryString | 否 | 查询条件表达式,如 ds>20201201 |
响应参数
名称 | 类型 | 描述 |
---|---|---|
partitions | List<PartitionInstance> | PartitionInstance实例结构体的列表 |
错误码
公有云标准错误返回码
Code | message | HTTP状态码 | 描述 |
---|---|---|---|
DatabaseNotFound | Database not found. | 404 | 数据库不存在 |
TableNotFound | Table not found. | 404 | 表不存在 |
InternalError | We encountered an internal error. Please try again. | 500 | 服务器内不错误 |
请求示例
Plain Text
1GET /v1/database/db_01/table/tb_01/partition?pageNo=1&pageSize=10 HTTP/1.1
2
3Host: edap.bj.baidubce.com
4
5Content-Length: 0
响应示例
Plain Text
1HTTP/1.1 200 OK
2
3Content-Length: xxxx
4
5Content-Type: application/json
6{
7 "pageNo": 1,
8 "pageSize": 10,
9 "totalSize": 1,
10 "partitions": [
11 {
12 "values": [
13 "1",
14 "hangzhou"
15 ],
16 "location": "bos://bucket/prefix",
17 "locationId": "loc1",
18 "properties": {
19 "p1": "v1"
20 },
21 "createTime": "2019-06-01T23:00:10Z"
22 }
23 ]
24}
ListPartitionNames
接口说明
获取表分区名称列表信息
请求原型
Plain Text
1GET /v1/database/${databaseName}/table/${tableName}/partition?names
请求参数
字段 | 类型 | 位置 | 是否必须 | 描述 |
---|---|---|---|---|
databaseName | String | URL | 是 | 数据库名 |
tableName | String | URL | 是 | 表名 |
filter | String | QueryString | 否 | 查询条件表达式,如 ds>20201201 |
响应参数
名称 | 类型 | 描述 |
---|---|---|
names | List<String> | 分区名列表 |
错误码
公有云标准错误返回码
Code | message | HTTP状态码 | 描述 |
---|---|---|---|
DatabaseNotFound | Database not found. | 404 | 数据库不存在 |
TableNotFound | Table not found. | 404 | 表不存在 |
InternalError | We encountered an internal error. Please try again. | 500 | 服务器内不错误 |
请求示例
Plain Text
1GET /v1/database/db_01/table/tb_01/partition?names HTTP/1.1
2
3Host: edap.bj.baidubce.com
4
5Content-Length: 0
响应示例
Plain Text
1HTTP/1.1 200 OK
2
3Content-Length: xxxx
4
5Content-Type: application/json
6{
7 "names": [
8 "id=1/age=12",
9 "id=2/age=11"
10 ]
11}
BatchGetPartitions
批量获取Table的分区信息
请求原型
Plain Text
1POST /v1/database/${databaseName}/table/${tableName}/partition?batchGet
请求头域
除公共头域外,无其它特殊头域。
请求参数
名称 | 类型 | 位置 | 是否必须 | 描述 |
---|---|---|---|---|
databaseName | String | URL | 是 | 数据库名 |
tableName | String | URL | 是 | 表名 |
needAuthProperties | Boolean | QueryString | 否 | 是否需要返回安全认证信息, 默认false |
partitionValuesList | List<List<String>> | Body | 是 | 分区值信息 |
响应参数
名称 | 类型 | 描述 |
---|---|---|
partitions | List<PartitionInstance> | Partition实例结构体的列表,详建PartitionInstance结构体 |
错误码
公有云标准错误返回码
Code | message | HTTP状态码 | 描述 |
---|---|---|---|
BadRequest | Bad request, please check your request | 400 | 请求体规则校验错误 |
DatabaseNotFound | Database not found. | 404 | 数据库不存在 |
TableNotFound | Table not found. | 404 | 表不存在 |
PartitionNotFound | Partitionnot found. | 404 | 分区不存在 |
InternalError | We encountered an internal error. Please try again. | 500 | 服务器内不错误 |
请求示例
Plain Text
1POST /v1/database/db_01/table/tb_01/partition?batchGet&needAuthProperties=true
2
3Host: edap.bj.baidubce.com
4
5Content-Length: xxxx
6
7Content-Type: application/json
8{
9 "partitionValuesList": [
10 {
11 "partitionValues": [
12 "1",
13 "hangzhou"
14 ]
15 },
16 {
17 "partitionValues": [
18 "2",
19 "shanghai"
20 ]
21 }
22 ]
23}
响应示例
Plain Text
1HTTP/1.1 200 OK
2
3Content-Length: xxxx
4
5Content-Type: application/json
6{
7 "partitions": [
8 {
9 "values": [
10 "1",
11 "hangzhou"
12 ],
13 "location": "bos://bucket/prefix",
14 "properties": {
15 "p1": "v1"
16 },
17 "createTime": "2019-06-01T23:00:10Z",
18 "authProperties": {
19 "accessKey": "key1",
20 "secretKey": "key2",
21 "sessionTokenKey": "key3"
22 }
23 },
24 {
25 "values": [
26 "1",
27 "shanghai"
28 ],
29 "location": "bos://bucket/shanghai",
30 "properties": {
31 "p1": "v1"
32 },
33 "createTime": "2019-06-01T23:00:11Z",
34 "authProperties": {
35 "accessKey": "key1",
36 "secretKey": "key2",
37 "sessionTokenKey": "key3"
38 }
39 }
40 ]
41}
BatchCreatePartitions
批量创建表格分区信息
请求原型
Plain Text
1POST /v1/database/<database-name>/table/<table-name>/partition?batchCreate
请求头域
除公共头域外,无其它特殊头域。
请求参数
名称 | 类型 | 位置 | 是否必须 | 描述 |
---|---|---|---|---|
databaseName | String | URL | 是 | 数据库名 |
tableName | String | URL | 是 | 表名 |
partitions | List<PartitionInstance> | Body | 是 | 分区信息,详情参见PartitionInstance结构体 |
响应参数
无
错误码
公有云标准错误返回码
Code | message | HTTP状态码 | 描述 |
---|---|---|---|
BadRequest | Bad request, please check your request | 400 | 请求体规则校验错误 |
DatabaseNotFound | Database not found. | 404 | 数据库不存在 |
TableNotFound | Table not found. | 404 | 表不存在 |
PartitionAlreadyExist | Partitionalready exist. | 409 | 分区已存在 |
InternalError | We encountered an internal error. Please try again. | 500 | 服务器内不错误 |
请求示例
Plain Text
1POST /v1/database/db_01/table/tb_01/partition?batchCreate
2
3Host: edap.bj.baidubce.com
4
5Content-Length: xxxx
6
7Content-Type: application/json
8{
9 "partitions": [
10 {
11 "values": [
12 "1",
13 "hangzhou"
14 ],
15 "location": "bos://bucket/hangzhou",
16 "properties": {
17 "p1": "v1"
18 }
19 },
20 {
21 "values": [
22 "2",
23 "guiyang"
24 ],
25 "location": "bos://bucket/guiyang",
26 "properties": {
27 "p1": "v1"
28 }
29 }
30 ]
31}{
32 "partitions": [
33 {
34 "values": [
35 "1",
36 "hangzhou"
37 ],
38 "location": "bos://bucket/hangzhou",
39 "properties": {
40 "p1": "v1"
41 }
42 },
43 {
44 "values": [
45 "2",
46 "guiyang"
47 ],
48 "location": "bos://bucket/guiyang",
49 "properties": {
50 "p1": "v1"
51 }
52 }
53 ]
54}
响应示例
Plain Text
1HTTP/1.1 204 No Content
2
3Content-Length: 0
BatchAlterPartitions
批量修改分区信息
请求原型
Plain Text
1PUT /v1/database/<databaseName>/table/<tableName>/partition?batchAlter
请求头域
除公共头域外,无其它特殊头域。
请求参数
名称 | 类型 | 位置 | 是否必须 | 描述 |
---|---|---|---|---|
databaseName | String | URL | 是 | 数据库名 |
tableName | String | URL | 是 | 表名 |
partitions | List<PartitionInstance> | Body | 是 | 分区信息,详情参见PartitionInstance结构体 |
响应参数
无
错误码
公有云标准错误返回码
Code | message | HTTP状态码 | 描述 |
---|---|---|---|
BadRequest | Bad request, please check your request | 400 | 请求体规则校验错误 |
DatabaseNotFound | Database not found. | 404 | 数据库不存在 |
TableNotFound | Table not found. | 404 | 表不存在 |
PartitionNotFound | Partitionnot found. | 404 | 分区不存在 |
InternalError | We encountered an internal error. Please try again. | 500 | 服务器内不错误 |
请求示例
Plain Text
1PUT /v1/database/db_01/table/tb_01/partition?batchAlter
2
3Host: edap.bj.baidubce.com
4
5Content-Length: xxxx
6
7Content-Type: application/json
8
9{
10
11 "partitions": [
12
13 {
14
15 "values": [
16
17 "1",
18
19 "hangzhou"
20
21 ],
22
23 "location": "bos://bucket/hangzhou",
24
25 "properties": {
26
27 "p1": "v1"
28
29 }
30
31 },
32
33 {
34
35 "values": [
36
37 "2",
38
39 "guiyang"
40
41 ],
42
43 "location": "bos://bucket/guiyang",
44
45 "properties": {
46
47 "p1": "v1"
48
49 }
50
51 }
52
53 ]
54
55}
响应示例
Plain Text
1HTTP/1.1 204 No Content
2
3Content-Length: 0
BatchDropPartitions
批量删除分区
请求原型
Plain Text
1POST /v1/database/${databaseName}/table/${tableName}/partition?batchDrop
请求头域
除公共头域外,无其它特殊头域。
请求参数
名称 | 类型 | 位置 | 是否必须 | 描述 |
---|---|---|---|---|
databaseName | String | URL | 是 | 数据库名 |
tableName | String | URL | 是 | 表名 |
partitionValuesList | List<List<String>> | Body | 是 | 分区值信息 |
响应参数
无
错误码
公有云标准错误返回码
Code | message | HTTP状态码 | 描述 |
---|---|---|---|
BadRequest | Bad request, please check your request | 400 | 请求体规则校验错误 |
DatabaseNotFound | Database not found. | 404 | 数据库不存在 |
TableNotFound | Table not found. | 404 | 表不存在 |
PartitionNotFound | Partitionnot found. | 404 | 分区不存在 |
InternalError | We encountered an internal error. Please try again. | 500 | 服务器内不错误 |
请求示例
Plain Text
1POST /v1/database/db_01/table/tb_01/partition?batchDrop
2
3Host: edap.bj.baidubce.com
4
5Content-Length: xxxx
6
7Content-Type: application/json
8{
9 "partitionValuesList": [
10 {
11 "partitionValues": [
12 "1",
13 "hangzhou"
14 ]
15 },
16 {
17 "partitionValues": [
18 "2",
19 "shanghai"
20 ]
21 }
22 ]
23}
响应示例
Plain Text
1HTTP/1.1 204 No Content
2
3Content-Length: 0
RenamePartition
重命名表分区。
请求原型
Plain Text
1POST /v1/database/<database-name>/table/<table-name>/partition?rename
请求头域
除公共头域外,无其它特殊头域。
请求参数
名称 | 类型 | 参数位置 | 是否必填 | 描述 |
---|---|---|---|---|
database | String | URL | 是 | 数据库名 |
tableName | String | URL | 是 | 表名 |
partitionValues | List<String> | Body | 是 | 旧的分区值 |
newPartition | PartitionInstance | Body | 是 | 新分区 |
响应参数
无
错误码
公有云标准错误返回码
Code | message | HTTP状态码 | 描述 |
---|---|---|---|
BadRequest | Bad request, please check your request | 400 | 请求体规则校验错误 |
DatabaseNotFound | Database not found. | 404 | 数据库不存在 |
TableNotFound | Table not found. | 404 | 表不存在 |
PartitionNotFound | Partitionnot found. | 404 | 分区不存在 |
InternalError | We encountered an internal error. Please try again. | 500 | 服务器内不错误 |
请求示例
Plain Text
1POST /v1/database/db_01/table/tb_01/partition?rename
2
3Host: edap.bj.baidubce.com
4
5Content-Length: xxxx
6
7Content-Type: application/json
8{
9 "database": "db_01",
10 "table": "tb_01",
11 "partitionValues": [
12 "2022-04-18"
13 ],
14 "newPartition": {
15 "partitionValues": [
16 "2022-04-19"
17 ],
18 "location": "bos://bucket/prefix",
19 "properties": {
20 "p1": "v1"
21 }
22 }
23}
响应示例
Plain Text
1HTTP/1.1 200 OK
2
3Content-Length: xxxx
4
5Content-Type: application/json