Skip to content

Commit

Permalink
feat(query): add some columns into information_schema.tables (databen…
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason authored and andylokandy committed Nov 27, 2023
1 parent 5e21cea commit 6e56a93
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DB.Table: 'system'.'columns', Table: columns-table_id:1, ver:0, Engine: SystemCo
| 'active_result_scan' | 'system' | 'query_cache' | 'Boolean' | 'BOOLEAN' | '' | '' | 'NO' | '' |
| 'auth_string' | 'system' | 'users' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'auth_type' | 'system' | 'users' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'auto_increment' | 'information_schema' | 'tables' | 'NULL' | 'NULL' | '' | '' | 'NO' | '' |
| 'cardinality' | 'information_schema' | 'statistics' | 'NULL' | 'NULL' | '' | '' | 'NO' | '' |
| 'cargo_features' | 'system' | 'build_options' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'catalog' | 'system' | 'databases' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
Expand Down Expand Up @@ -56,6 +57,7 @@ DB.Table: 'system'.'columns', Table: columns-table_id:1, ver:0, Engine: SystemCo
| 'current_database' | 'system' | 'query_log' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'data_compressed_size' | 'system' | 'tables' | 'Nullable(UInt64)' | 'BIGINT UNSIGNED' | '' | '' | 'YES' | '' |
| 'data_compressed_size' | 'system' | 'tables_with_history' | 'Nullable(UInt64)' | 'BIGINT UNSIGNED' | '' | '' | 'YES' | '' |
| 'data_free' | 'information_schema' | 'tables' | 'NULL' | 'NULL' | '' | '' | 'NO' | '' |
| 'data_length' | 'information_schema' | 'tables' | 'Nullable(UInt64)' | 'BIGINT UNSIGNED' | '' | '' | 'YES' | '' |
| 'data_read_bytes' | 'system' | 'processes' | 'UInt64' | 'BIGINT UNSIGNED' | '' | '' | 'NO' | '' |
| 'data_size' | 'system' | 'tables' | 'Nullable(UInt64)' | 'BIGINT UNSIGNED' | '' | '' | 'YES' | '' |
Expand Down Expand Up @@ -229,6 +231,7 @@ DB.Table: 'system'.'columns', Table: columns-table_id:1, ver:0, Engine: SystemCo
| 'table_catalog' | 'information_schema' | 'statistics' | 'NULL' | 'NULL' | '' | '' | 'NO' | '' |
| 'table_catalog' | 'information_schema' | 'tables' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'table_catalog' | 'information_schema' | 'views' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'table_collation' | 'information_schema' | 'tables' | 'NULL' | 'NULL' | '' | '' | 'NO' | '' |
| 'table_comment' | 'information_schema' | 'tables' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'table_id' | 'system' | 'tables' | 'UInt64' | 'BIGINT UNSIGNED' | '' | '' | 'NO' | '' |
| 'table_id' | 'system' | 'tables_with_history' | 'UInt64' | 'BIGINT UNSIGNED' | '' | '' | 'NO' | '' |
Expand All @@ -237,6 +240,7 @@ DB.Table: 'system'.'columns', Table: columns-table_id:1, ver:0, Engine: SystemCo
| 'table_name' | 'information_schema' | 'statistics' | 'NULL' | 'NULL' | '' | '' | 'NO' | '' |
| 'table_name' | 'information_schema' | 'tables' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'table_name' | 'information_schema' | 'views' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'table_rows' | 'information_schema' | 'tables' | 'Nullable(UInt64)' | 'BIGINT UNSIGNED' | '' | '' | 'YES' | '' |
| 'table_schema' | 'information_schema' | 'columns' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'table_schema' | 'information_schema' | 'key_column_usage' | 'NULL' | 'NULL' | '' | '' | 'NO' | '' |
| 'table_schema' | 'information_schema' | 'statistics' | 'NULL' | 'NULL' | '' | '' | 'NO' | '' |
Expand Down
30 changes: 30 additions & 0 deletions src/query/storages/information-schema/src/tables_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@ use common_storages_view::view_table::QUERY;
pub struct TablesTable {}

impl TablesTable {
// desc information_schema.tables;
// +-----------------+--------------------------------------------------------------------+------+-----+---------+-------+
// | Field | Type | Null | Key | Default | Extra |
// +-----------------+--------------------------------------------------------------------+------+-----+---------+-------+
// | TABLE_CATALOG | varchar(64) | NO | | NULL | |
// | TABLE_SCHEMA | varchar(64) | NO | | NULL | |
// | TABLE_NAME | varchar(64) | NO | | NULL | |
// | TABLE_TYPE | enum('BASE TABLE','VIEW','SYSTEM VIEW') | NO | | NULL | |
// | ENGINE | varchar(64) | YES | | NULL | |
// | VERSION | int | YES | | NULL | |
// | ROW_FORMAT | enum('Fixed','Dynamic','Compressed','Redundant','Compact','Paged') | YES | | NULL | |
// | TABLE_ROWS | bigint unsigned | YES | | NULL | |
// | AVG_ROW_LENGTH | bigint unsigned | YES | | NULL | |
// | DATA_LENGTH | bigint unsigned | YES | | NULL | |
// | MAX_DATA_LENGTH | bigint unsigned | YES | | NULL | |
// | INDEX_LENGTH | bigint unsigned | YES | | NULL | |
// | DATA_FREE | bigint unsigned | YES | | NULL | |
// | AUTO_INCREMENT | bigint unsigned | YES | | NULL | |
// | CREATE_TIME | timestamp | NO | | NULL | |
// | UPDATE_TIME | datetime | YES | | NULL | |
// | CHECK_TIME | datetime | YES | | NULL | |
// | TABLE_COLLATION | varchar(64) | YES | | NULL | |
// | CHECKSUM | bigint | YES | | NULL | |
// | CREATE_OPTIONS | varchar(256) | YES | | NULL | |
// | TABLE_COMMENT | text | YES | | NULL | |
// +-----------------+--------------------------------------------------------------------+------+-----+---------+-------+
pub fn create(table_id: u64) -> Arc<dyn Table> {
let query = "SELECT
database AS table_catalog,
Expand All @@ -36,6 +62,10 @@ impl TablesTable {
dropped_on AS drop_time,
data_size AS data_length,
index_size AS index_length,
num_rows AS table_rows,
NULL AS auto_increment,
NULL AS table_collation,
NULL AS data_free,
'' AS table_comment
FROM system.tables;";

Expand Down

0 comments on commit 6e56a93

Please sign in to comment.