Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Append LIST partition info when list table partitions by rest api. #53382

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

plotor
Copy link
Contributor

@plotor plotor commented Nov 29, 2024

Why I'm doing:

You can learn about the background from PR #52682.

What I'm doing:

This PR is a supplement to #41938, and append LIST partition info when list table's partitions by RESTful API. For example, for the following LIST partition table:

CREATE TABLE `tb_list_partition` (
  `c0` bigint(20) NOT NULL COMMENT "cc0",
  `c1` datetime NOT NULL COMMENT "cc1",
  `c2` varchar(32) NOT NULL COMMENT "cc2",
  `c3` decimal(32, 8) NULL DEFAULT "0" COMMENT "cc3",
  `c4` array<int(11)> NULL COMMENT "cc4",
  `c5` struct<C4_a int(11), c4_b struct<c4_b_1 varchar(65533)>> NULL COMMENT "cc5",
  `c6` map<bigint(20),map<int(11),varchar(65533)>> NOT NULL COMMENT "cc6",
  `c7` json NOT NULL COMMENT "cc7",
  `c8` bitmap NOT NULL COMMENT "cc8",
  `c9` hll NOT NULL COMMENT "cc9",
  INDEX idx_bitmap (`c9`) USING BITMAP COMMENT ''
) ENGINE=OLAP
PRIMARY KEY(`c0`, `c1`, `c2`)
PARTITION BY LIST(`c2`)(
  PARTITION p1 VALUES IN ('beijing'),
  PARTITION p2 VALUES IN ('shanghai', 'hangzhou'),
  PARTITION p3 VALUES IN ('guangzhou', 'shenzhen'),
  PARTITION p4 VALUES IN ('chengdu', 'chongqing')
)
DISTRIBUTED BY HASH(`c0`) BUCKETS 8
PROPERTIES (
"enable_persistent_index" = "true",
"replication_num" = "3"
);

The /api/v2/catalogs/{catalog}/databases/{db}/tables/{table}/partition API will return the LIST partition information through the inKeys field:

{
    "result": {
        "pageNum": 0,
        "pageSize": 100,
        "pages": 1,
        "total": 4,
        "items": [
            {
                "id": 10321,
                "name": "p1",
                "bucketNum": 8,
                "distributionType": "HASH",
                "visibleVersion": 1,
                "visibleVersionTime": 1732870030714,
                "nextVersion": 2,
                "inKeys": [
                    [
                        "beijing"
                    ]
                ],
                "tablets": [
                    ...
                ]
            },
            {
                "id": 10322,
                "name": "p2",
                "bucketNum": 8,
                "distributionType": "HASH",
                "visibleVersion": 1,
                "visibleVersionTime": 1732870030715,
                "nextVersion": 2,
                "inKeys": [
                    [
                        "shanghai"
                    ],
                    [
                        "hangzhou"
                    ]
                ],
                "tablets": [
                    ...
                ]
            },
            {
                "id": 10323,
                "name": "p3",
                "bucketNum": 8,
                "distributionType": "HASH",
                "visibleVersion": 1,
                "visibleVersionTime": 1732870030715,
                "nextVersion": 2,
                "inKeys": [
                    [
                        "guangzhou"
                    ],
                    [
                        "shenzhen"
                    ]
                ],
                "tablets": [
                    ...
                ]
            },
            {
                "id": 10324,
                "name": "p4",
                "bucketNum": 8,
                "distributionType": "HASH",
                "visibleVersion": 1,
                "visibleVersionTime": 1732870030715,
                "nextVersion": 2,
                "inKeys": [
                    [
                        "chengdu"
                    ],
                    [
                        "chongqing"
                    ]
                ],
                "tablets": [
                    ...
                ]
            }
        ]
    },
    "code": "0",
    "message": "OK"
}

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.4
    • 3.3
    • 3.2
    • 3.1
    • 3.0

@plotor plotor requested review from a team as code owners November 29, 2024 11:28
@wanpengfei-git wanpengfei-git requested a review from a team November 29, 2024 11:29
@mergify mergify bot assigned plotor Nov 29, 2024
@plotor plotor force-pushed the zhenchao-bypass-list-partition-20241129 branch 3 times, most recently from 69b386e to ef6b979 Compare December 4, 2024 07:25
…y rest api.

Signed-off-by: plotor <zhenchao.wang@hotmail.com>
@plotor plotor force-pushed the zhenchao-bypass-list-partition-20241129 branch from ef6b979 to e3726b0 Compare December 4, 2024 10:27
Copy link

sonarqubecloud bot commented Dec 4, 2024

Copy link

github-actions bot commented Dec 4, 2024

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

github-actions bot commented Dec 4, 2024

[FE Incremental Coverage Report]

pass : 33 / 41 (80.49%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/load/loadv2/SparkLoadPendingTask.java 0 3 00.00% [394, 395, 396]
🔵 com/starrocks/http/rest/TableQueryPlanAction.java 2 7 28.57% [223, 224, 266, 282, 290]
🔵 com/starrocks/load/PartitionUtils.java 16 16 100.00% []
🔵 com/starrocks/http/rest/v2/vo/PartitionInfoView.java 15 15 100.00% []

Copy link

github-actions bot commented Dec 4, 2024

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

@wyb wyb enabled auto-merge (squash) December 12, 2024 01:14
@wyb wyb merged commit 019de3a into StarRocks:main Dec 16, 2024
55 of 57 checks passed
@kevincai
Copy link
Contributor

how about the pagination, is it taken care in the rest api ? @plotor

@plotor
Copy link
Contributor Author

plotor commented Dec 16, 2024

how about the pagination, is it taken care in the rest api ? @plotor

@kevincai The reason for introducing pagination is that some tables may have too many partitions, which may cause the API response time to be longer or unavailable. As described in #41938, there are 4 control params for pagination (which borrowed from the traditional Java Web project API design):

param desc
pageNum The page number in request.
pageSize The page size in request.
pages Total page size.
total Total item size.

Users can obtain all partitions of the table in the following way:

int pageNum = 0;
while (true) {
    PagedResult<TablePartition> pagedResult =
            listTablePartitions(catalog, database, table, temporary, pageNum, pageSize);
    partitions.addAll(pagedResult.getItems());
    // Loop until the page parameter reaches the value in the request response.
    if (++pageNum >= pagedResult.getPages()) {
        break;
    }
}

And we will provide REST API SDK in subsequent PRs latter, which will simplify the call of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants