-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[feature](analyze_cmd) add show-tablets-belong stmt for analyzing a batch of tablet-ids #27994
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
docs/en/docs/sql-manual/sql-reference/Show-Statements/SHOW-TABLETS-BELONG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| --- | ||
| { | ||
| "title": "SHOW-TABLETS-BELONG", | ||
| "language": "en" | ||
| } | ||
| --- | ||
|
|
||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| --> | ||
|
|
||
| <version since="dev"> | ||
|
|
||
| ## SHOW-TABLETS-BELONG | ||
|
|
||
| </version> | ||
|
|
||
| ### Name | ||
|
|
||
| SHOW TABLETS BELONG | ||
|
|
||
| ### Description | ||
|
|
||
| Used to show tablets and information of their belonging table | ||
|
|
||
| grammar: | ||
|
|
||
| ```sql | ||
| SHOW TABLETS BELONG tablet-ids; | ||
| ``` | ||
|
|
||
| illustrate: | ||
|
|
||
| 1. tablet-ids:one or more tablet-ids, with comma separated | ||
| 2. Columns of result keep same with result of `SHOW-DATA` for the same table | ||
|
|
||
| ### Example | ||
|
|
||
| 1. show information of four tablet-ids (actually, three tablet-ids. Result will be deduplicated) | ||
|
|
||
| ```sql | ||
| SHOW TABLETS BELONG 27028,78880,78382,27028; | ||
| ``` | ||
|
|
||
| ``` | ||
| +---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ | ||
| | DbName | TableName | TableSize | PartitionNum | BucketNum | ReplicaCount | TabletIds | | ||
| +---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ | ||
| | default_cluster:db1 | kec | 613.000 B | 379 | 604 | 604 | [78880, 78382] | | ||
| | default_cluster:db1 | test | 1.874 KB | 1 | 1 | 1 | [27028] | | ||
| +---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ | ||
| ``` | ||
|
|
||
| ### Keywords | ||
|
|
||
| SHOW, TABLETS, BELONG | ||
|
|
||
| ### Best Practice | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
docs/zh-CN/docs/sql-manual/sql-reference/Show-Statements/SHOW-TABLETS-BELONG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| --- | ||
| { | ||
| "title": "SHOW-TABLETS-BELONG", | ||
| "language": "zh-CN" | ||
| } | ||
| --- | ||
|
|
||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| --> | ||
|
|
||
| <version since="dev"> | ||
|
|
||
| ## SHOW-TABLETS-BELONG | ||
|
|
||
| </version> | ||
|
|
||
| ### Name | ||
|
|
||
| SHOW TABLETS BELONG | ||
|
|
||
| ### Description | ||
|
|
||
| 该语句用于展示指定Tablets归属的表的信息 | ||
|
|
||
| 语法: | ||
|
|
||
| ```sql | ||
| SHOW TABLETS BELONG tablet-ids; | ||
| ``` | ||
|
|
||
| 说明: | ||
|
|
||
| 1. tablet-ids:代表一到多个tablet-id构成的列表。如有多个,使用逗号分隔 | ||
| 2. 结果中 table 相关的信息和 `SHOW-DATA` 语句的口径一致 | ||
|
|
||
| ### Example | ||
|
|
||
| 1. 展示3个tablet-id的相关信息(tablet-id可去重) | ||
|
|
||
| ```sql | ||
| SHOW TABLETS BELONG 27028,78880,78382,27028; | ||
| ``` | ||
|
|
||
| ``` | ||
| +---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ | ||
| | DbName | TableName | TableSize | PartitionNum | BucketNum | ReplicaCount | TabletIds | | ||
| +---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ | ||
| | default_cluster:db1 | kec | 613.000 B | 379 | 604 | 604 | [78880, 78382] | | ||
| | default_cluster:db1 | test | 1.874 KB | 1 | 1 | 1 | [27028] | | ||
| +---------------------+-----------+-----------+--------------+-----------+--------------+----------------+ | ||
| ``` | ||
|
|
||
| ### Keywords | ||
|
|
||
| SHOW, TABLETS, BELONG | ||
|
|
||
| ### Best Practice | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
fe/fe-core/src/main/java/org/apache/doris/analysis/ShowTabletsBelongStmt.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| package org.apache.doris.analysis; | ||
|
|
||
| import org.apache.doris.catalog.Column; | ||
| import org.apache.doris.catalog.ScalarType; | ||
| import org.apache.doris.common.UserException; | ||
| import org.apache.doris.qe.ShowResultSetMetaData; | ||
|
|
||
| import com.google.common.collect.ImmutableList; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * ShowTabletsBelongStmt is used to show information of tables which tablets are belonged to | ||
| * syntax: | ||
| * SHOW TABLETS BELONG tablet_ids | ||
| */ | ||
| public class ShowTabletsBelongStmt extends ShowStmt { | ||
| private List<Long> tabletIds; | ||
|
|
||
| private static final ImmutableList<String> TITLE_NAMES = new ImmutableList.Builder<String>() | ||
| .add("DbName") | ||
| .add("TableName") | ||
| .add("TableSize") | ||
| .add("PartitionNum") | ||
| .add("BucketNum") | ||
| .add("ReplicaCount") | ||
| .add("TabletIds") | ||
| .build(); | ||
|
|
||
| public ShowTabletsBelongStmt(List<Long> tabletIds) { | ||
| this.tabletIds = tabletIds; | ||
| } | ||
|
|
||
| public List<Long> getTabletIds() { | ||
| return tabletIds; | ||
| } | ||
|
|
||
| @Override | ||
| public void analyze(Analyzer analyzer) throws UserException { | ||
| if (tabletIds == null || tabletIds.isEmpty()) { | ||
| throw new UserException("Please supply at least one tablet id"); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public ShowResultSetMetaData getMetaData() { | ||
| ShowResultSetMetaData.Builder builder = ShowResultSetMetaData.builder(); | ||
| for (String title : TITLE_NAMES) { | ||
| builder.addColumn(new Column(title, ScalarType.createVarchar(128))); | ||
| } | ||
| return builder.build(); | ||
| } | ||
|
|
||
| @Override | ||
| public RedirectStatus getRedirectStatus() { | ||
| return RedirectStatus.FORWARD_NO_SYNC; | ||
| } | ||
|
|
||
| @Override | ||
| public String toSql() { | ||
| StringBuilder sb = new StringBuilder(); | ||
| sb.append("SHOW TABLETS BELONG "); | ||
|
|
||
| for (long tabletId : tabletIds) { | ||
| sb.append(tabletId); | ||
| sb.append(", "); | ||
| } | ||
|
|
||
| String tmp = sb.toString(); | ||
| return tmp.substring(tmp.length() - 1); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return toSql(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.