[improvement] Support show tablets stmt (#7970)

change `show tablet from tbl` to `show tablets from tbl`
This commit is contained in:
ChPi
2022-03-05 15:25:57 +08:00
committed by GitHub
parent f52d479cbc
commit f57f02bbf2
6 changed files with 132 additions and 40 deletions

View File

@ -26,17 +26,14 @@ under the License.
# SHOW TABLET
## Description
This statement is used to display tablet-related information (for administrators only)
Grammar:
SHOW TABLET
[From [db-uu name]] table U name.; Table U Id]
This statement is used to display information of the specified tablet (for administrators only)
Grammar:
SHOW TABLET tablet_id
## example
1. Display all tablet information in the specified table below the specified DB
SHOW TABLET FROM example_db.table_name;
2. Display parent level ID information of tablet with specified tablet ID of 10000
Performance board 10000;
// Display parent level ID information of tablet with specified tablet id of 10000
SHOW TABLET 10000;
## keyword
SHOW,TABLET

View File

@ -0,0 +1,56 @@
---
{
"title": "SHOW TABLETS",
"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.
-->
# SHOW TABLETS
## Description
This statement is used to display tablet-related information (for administrators only)
Grammar:
SHOW TABLETS
[FROM [db_name.]table_name] [partiton(partition_name_1, partition_name_1)]
[where [version=1] [and backendid=10000] [and state="NORMAL|ROLLUP|CLONE|DECOMMISSION"]]
[order by order_column]
[limit [offset,]size]
## example
// Display all tablets information in the specified table below the specified DB
SHOW TABLETS FROM example_db.table_name;
SHOW TABLETS FROM example_db.table_name partition(p1, p2);
// display 10 tablets information in the table
SHOW TABLETS FROM example_db.table_name limit 10;
SHOW TABLETS FROM example_db.table_name limit 5,10;
// display the tablets that fulfill some conditions
SHOW TABLETS FROM example_db.table_name where backendid=10000 and version=1 and state="NORMAL";
SHOW TABLETS FROM example_db.table_name where backendid=10000 order by version;
SHOW TABLETS FROM example_db.table_name where indexname="t1_rollup";
## keyword
SHOW,TABLETS,LIMIT

View File

@ -26,40 +26,13 @@ under the License.
# SHOW TABLET
## description
该语句用于显示 tablet 相关的信息(仅管理员使用)
该语句用于显示指定tablet id 信息(仅管理员使用)
语法:
SHOW TABLET
[FROM [db_name.]table_name | tablet_id] [partiton(partition_name_1, partition_name_1)]
[where [version=1] [and backendid=10000] [and state="NORMAL|ROLLUP|CLONE|DECOMMISSION"]]
[order by order_column]
[limit [offset,]size]
SHOW TABLET tablet_id
现在show tablet命令支持按照按照以下字段进行过滤:partition, index name, version, backendid,
state,同时支持按照任意字段进行排序,并且提供limit限制返回条数。
## example
1. 显示指定 db 的下指定表所有 tablet 信息
SHOW TABLET FROM example_db.table_name;
// 获取partition p1和p2的tablet信息
SHOW TABLET FROM example_db.table_name partition(p1, p2);
// 获取10个结果
SHOW TABLET FROM example_db.table_name limit 10;
// 从偏移5开始获取10个结果
SHOW TABLET FROM example_db.table_name limit 5,10;
// 按照backendid/version/state字段进行过滤
SHOW TABLET FROM example_db.table_name where backendid=10000 and version=1 and state="NORMAL";
// 按照version字段进行排序
SHOW TABLET FROM example_db.table_name where backendid=10000 order by version;
// 获取index名字为t1_rollup的tablet相关信息
SHOW TABLET FROM example_db.table_name where indexname="t1_rollup";
2. 显示指定 tablet id 为 10000 的 tablet 的父层级 id 信息
// 显示指定 tablet id 为 10000 的 tablet 的父层级 id 信息
SHOW TABLET 10000;
## keyword

View File

@ -0,0 +1,65 @@
---
{
"title": "SHOW TABLETS",
"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.
-->
# SHOW TABLETS
## description
该语句用于显示 tablet 相关的信息(仅管理员使用)
语法:
SHOW TABLETS
[FROM [db_name.]table_name] [partiton(partition_name_1, partition_name_1)]
[where [version=1] [and backendid=10000] [and state="NORMAL|ROLLUP|CLONE|DECOMMISSION"]]
[order by order_column]
[limit [offset,]size]
现在show tablets命令支持按照按照以下字段进行过滤:partition, index name, version, backendid,
state,同时支持按照任意字段进行排序,并且提供limit限制返回条数。
## example
// 显示指定 db 的下指定表所有 tablet 信息
SHOW TABLETS FROM example_db.table_name;
// 获取partition p1和p2的tablet信息
SHOW TABLETS FROM example_db.table_name partition(p1, p2);
// 获取10个结果
SHOW TABLETS FROM example_db.table_name limit 10;
// 从偏移5开始获取10个结果
SHOW TABLETS FROM example_db.table_name limit 5,10;
// 按照backendid/version/state字段进行过滤
SHOW TABLETS FROM example_db.table_name where backendid=10000 and version=1 and state="NORMAL";
// 按照version字段进行排序
SHOW TABLETS FROM example_db.table_name where backendid=10000 order by version;
// 获取index名字为t1_rollup的tablet相关信息
SHOW TABLETS FROM example_db.table_name where indexname="t1_rollup";
## keyword
SHOW,TABLETS,LIMIT

View File

@ -267,7 +267,7 @@ terminal String KW_ADD, KW_ADMIN, KW_AFTER, KW_AGGREGATE, KW_ALIAS, KW_ALL, KW_A
KW_SKEW,
KW_SMALLINT, KW_SNAPSHOT, KW_SONAME, KW_SPLIT, KW_START, KW_STATUS, KW_STATS, KW_STOP, KW_STORAGE, KW_STREAM, KW_STRING, KW_STRUCT,
KW_SUM, KW_SUPERUSER, KW_SYNC, KW_SYSTEM,
KW_TABLE, KW_TABLES, KW_TABLET, KW_TASK, KW_TEMPORARY, KW_TERMINATED, KW_TEXT, KW_THAN, KW_TIME, KW_THEN, KW_TIMESTAMP, KW_TINYINT,KW_TRASH,
KW_TABLE, KW_TABLES, KW_TABLET, KW_TABLETS, KW_TASK, KW_TEMPORARY, KW_TERMINATED, KW_TEXT, KW_THAN, KW_TIME, KW_THEN, KW_TIMESTAMP, KW_TINYINT,KW_TRASH,
KW_TO, KW_TRANSACTION, KW_TRIGGERS, KW_TRIM, KW_TRUE, KW_TRUNCATE, KW_TYPE, KW_TYPES,
KW_UNCOMMITTED, KW_UNBOUNDED, KW_UNION, KW_UNIQUE, KW_UNLOCK, KW_UNSIGNED, KW_USE, KW_USER, KW_USING, KW_UNINSTALL,
KW_VALUE, KW_VALUES, KW_VARCHAR, KW_VARIABLES, KW_VERBOSE, KW_VIEW,
@ -2756,7 +2756,7 @@ show_param ::=
{:
RESULT = new ShowTabletStmt(null, tabletId);
:}
| KW_TABLET KW_FROM table_name:dbTblName opt_partition_names:partitionNames opt_wild_where order_by_clause:orderByClause limit_clause:limitClause
| KW_TABLETS KW_FROM table_name:dbTblName opt_partition_names:partitionNames opt_wild_where order_by_clause:orderByClause limit_clause:limitClause
{:
RESULT = new ShowTabletStmt(dbTblName, -1L, partitionNames, parser.where, orderByClause, limitClause);
:}

View File

@ -421,6 +421,7 @@ import org.apache.doris.qe.SqlModeHelper;
keywordMap.put("year", new Integer(SqlParserSymbols.KW_YEAR));
keywordMap.put("||", new Integer(SqlParserSymbols.KW_PIPE));
keywordMap.put("sql_block_rule", new Integer(SqlParserSymbols.KW_SQL_BLOCK_RULE));
keywordMap.put("tablets", new Integer(SqlParserSymbols.KW_TABLETS));
}
// map from token id to token description