From f57f02bbf24ece92a2ba3d76e4ab64b644442ab7 Mon Sep 17 00:00:00 2001 From: ChPi Date: Sat, 5 Mar 2022 15:25:57 +0800 Subject: [PATCH] [improvement] Support show tablets stmt (#7970) change `show tablet from tbl` to `show tablets from tbl` --- .../Data Manipulation/SHOW TABLET.md | 13 ++-- .../Data Manipulation/SHOW TABLETS.md | 56 ++++++++++++++++ .../Data Manipulation/SHOW TABLET.md | 33 +--------- .../Data Manipulation/SHOW TABLETS.md | 65 +++++++++++++++++++ fe/fe-core/src/main/cup/sql_parser.cup | 4 +- fe/fe-core/src/main/jflex/sql_scanner.flex | 1 + 6 files changed, 132 insertions(+), 40 deletions(-) create mode 100644 docs/en/sql-reference/sql-statements/Data Manipulation/SHOW TABLETS.md create mode 100644 docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW TABLETS.md diff --git a/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW TABLET.md b/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW TABLET.md index 17a559e15e..21ccbccd0a 100644 --- a/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW TABLET.md +++ b/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW TABLET.md @@ -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 diff --git a/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW TABLETS.md b/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW TABLETS.md new file mode 100644 index 0000000000..0ed338d5af --- /dev/null +++ b/docs/en/sql-reference/sql-statements/Data Manipulation/SHOW TABLETS.md @@ -0,0 +1,56 @@ +--- +{ + "title": "SHOW TABLETS", + "language": "en" +} +--- + + + +# 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 diff --git a/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW TABLET.md b/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW TABLET.md index fc6fb77684..d2de94f73a 100644 --- a/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW TABLET.md +++ b/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW TABLET.md @@ -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 diff --git a/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW TABLETS.md b/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW TABLETS.md new file mode 100644 index 0000000000..113a69ea7d --- /dev/null +++ b/docs/zh-CN/sql-reference/sql-statements/Data Manipulation/SHOW TABLETS.md @@ -0,0 +1,65 @@ +--- +{ + "title": "SHOW TABLETS", + "language": "zh-CN" +} +--- + + + +# 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 + diff --git a/fe/fe-core/src/main/cup/sql_parser.cup b/fe/fe-core/src/main/cup/sql_parser.cup index a29946f104..dc2ee4183a 100644 --- a/fe/fe-core/src/main/cup/sql_parser.cup +++ b/fe/fe-core/src/main/cup/sql_parser.cup @@ -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); :} diff --git a/fe/fe-core/src/main/jflex/sql_scanner.flex b/fe/fe-core/src/main/jflex/sql_scanner.flex index 86ccd72914..6f356569ce 100644 --- a/fe/fe-core/src/main/jflex/sql_scanner.flex +++ b/fe/fe-core/src/main/jflex/sql_scanner.flex @@ -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