diff --git a/src/query/service/tests/it/storages/testdata/columns_table.txt b/src/query/service/tests/it/storages/testdata/columns_table.txt index c385ddd4957d7..e138d82a2b710 100644 --- a/src/query/service/tests/it/storages/testdata/columns_table.txt +++ b/src/query/service/tests/it/storages/testdata/columns_table.txt @@ -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' | '' | @@ -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' | '' | @@ -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' | '' | @@ -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' | '' | diff --git a/src/query/storages/information-schema/src/tables_table.rs b/src/query/storages/information-schema/src/tables_table.rs index e97e81130ff5e..f8d4fe64bad4d 100644 --- a/src/query/storages/information-schema/src/tables_table.rs +++ b/src/query/storages/information-schema/src/tables_table.rs @@ -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 { let query = "SELECT database AS table_catalog, @@ -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;";