-
Notifications
You must be signed in to change notification settings - Fork 276
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
Redesign partition view #10996
Closed
Closed
Redesign partition view #10996
Conversation
This file contains 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
qingxinhome
requested review from
nnsgmsone,
zhangxu19830126,
ouyuanning,
aunjgr,
badboynt1,
iamlinjunhong,
daviszhen,
aressu1985,
heni02 and
sukki37
as code owners
August 3, 2023 01:54
…one into RedesignPartitionView
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What type of PR is this?
Which issue(s) this PR fixes:
issue #10281
What this PR does / why we need it:
为了更方便的查询和分析mo的分区表,以及支持兼容mysql的navicat工具,本PR实现了如下主要功能
在mo_catalog下新增一个元数据表
mo_table_partitions
,用于存放分区表详细的分区信息具体细节如下:
在mo_catalog下新增一个元数据表
mo_table_partitions
,用于存放分区表详细的分区信息-> table_id :
当前分区表的ID。
-> database_id :
当前分区表所属的数据库的ID。
-> number :
当前分区编号,所有分区都按照定义的顺序进行索引,其中1是分配给第一个分区的数字。索引可以随着分区的添加、删除和重新组织而更改;
显示的数字是,此列反映当前顺序,并考虑了任何索引更改。
-> name :
分区的名称
->
partition_type
:存放表的分区类型信息,如果是分区表,其值枚举为"KEY", "LINEAR_KEY","HASH", "LINEAR_KEY_51", "RANGE", "RANGE_COLUMNS", "LIST", "LIST_COLUMNS",
如果不是分区表,
partition_type
的值为空字符串->
partition_expression
:创建分区表的的CREATE TABLE或ALTER TABLE语句中使用的分区函数的表达式。例如,考虑使用以下语句在测试数据库中创建的分区表:
CREATE TABLE tp (
c1 INT,
c2 INT,
c3 VARCHAR(25)
)
PARTITION BY HASH(c1 + c2)
PARTITIONS 4;
此表中分区的PARTITIONS_EXPRESSION表行中的PARTITION _EXPRESSION列显示c1+c2
-> description_utf8 :
此列用于RANGE和LIST分区。对于RANGE分区,它包含分区的VALUES LESS THAN子句中设置的值,该值可以是整数或MAXVALUE。对于LIST分区,此列包含分区的values in子句中定义的值,该子句是逗号分隔的整数值列表。
对于不是RANGE或LIST的分区,此列始终为NULL。
-> comment :
注释的文本(如果分区有注释的话)。否则,此值为空。
-> options :
分区的选项信息,暂时为NULL
-> partition_table_name :
当前分区对应的分区子表名字
在information_schema下新增一个系统视图PARTITIONS,以兼容mysql的information_schema.PARTITIONS系统视图
PARTITIONS表提供了有关表分区的信息。该表中的每一行都对应于分区表的一个单独分区或子分区。
有关分区表的更多信息,请参阅MYSQL官网链接:https://dev.mysql.com/doc/refman/8.0/en/information-schema-partitions-table.html
该视图的定义如下:
CREATE VIEW
PARTITIONS
ASSELECT
'def' AS
TABLE_CATALOG
,tbl
.reldatabase
ASTABLE_SCHEMA
,tbl
.relname
ASTABLE_NAME
,part
.name
ASPARTITION_NAME
,NULL AS
SUBPARTITION_NAME
,part
.number
ASPARTITION_ORDINAL_POSITION
,NULL AS
SUBPARTITION_ORDINAL_POSITION
,(case
part
.partition_type
when 'HASH' then 'HASH' when 'RANGE' then 'RANGE' when 'LIST' then 'LIST' when 'AUTO' then 'AUTO' when 'KEY_51' then 'KEY' when 'KEY_55' then 'KEY' when 'LINEAR_KEY_51' then 'LINEAR KEY' when 'LINEAR_KEY_55' then 'LINEAR KEY' when 'LINEAR_HASH' then 'LINEAR HASH' when 'RANGE_COLUMNS' then 'RANGE COLUMNS' when 'LIST_COLUMNS' then 'LIST COLUMNS' else NULL end) ASPARTITION_METHOD
,NULL AS
SUBPARTITION_METHOD
,part
.partition_expression
ASPARTITION_EXPRESSION
,NULL AS
SUBPARTITION_EXPRESSION
,part
.description_utf8
ASPARTITION_DESCRIPTION
,mo_table_rows(
tbl
.reldatabase
,part
.partition_table_name
) ASTABLE_ROWS
,0 AS
AVG_ROW_LENGTH
,0 AS
DATA_LENGTH
,0 AS
MAX_DATA_LENGTH
,0 AS
INDEX_LENGTH
,0 AS
DATA_FREE
,tbl
.created_time
ASCREATE_TIME
,NULL AS
UPDATE_TIME
,NULL AS
CHECK_TIME
,NULL AS
CHECKSUM
,ifnull(
part
.comment
,'') ASPARTITION_COMMENT
,'default' AS
NODEGROUP
,NULL AS
TABLESPACE_NAME
FROM
mo_catalog
.mo_tables
tbl
LEFT JOINmo_catalog
.mo_table_partitions
part
ON
part
.table_id
=tbl
.rel_id
WHERE
tbl
.partitioned
= 1;