Skip to content

Commit

Permalink
chore(query): add column: system.tables.total_columns
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason committed Sep 12, 2024
1 parent 2ca0036 commit fcadc3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ DB.Table: 'system'.'columns', Table: columns-table_id:1, ver:0, Engine: SystemCo
| 'task_type' | 'system' | 'background_jobs' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'tenant_id' | 'system' | 'query_log' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'time' | 'system' | 'processes' | 'UInt64' | 'BIGINT UNSIGNED' | '' | '' | 'NO' | '' |
| 'total_columns' | 'system' | 'tables' | 'UInt64' | 'BIGINT UNSIGNED' | '' | '' | 'NO' | '' |
| 'total_columns' | 'system' | 'tables_with_history' | 'UInt64' | 'BIGINT UNSIGNED' | '' | '' | 'NO' | '' |
| 'total_partitions' | 'system' | 'query_log' | 'UInt64' | 'BIGINT UNSIGNED' | '' | '' | 'NO' | '' |
| 'trigger' | 'system' | 'background_tasks' | 'Nullable(String)' | 'VARCHAR' | '' | '' | 'YES' | '' |
| 'type' | 'system' | 'background_tasks' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
Expand Down
9 changes: 9 additions & 0 deletions src/query/storages/system/src/tables_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
TableField::new("database", TableDataType::String),
TableField::new("name", TableDataType::String),
TableField::new("table_id", TableDataType::Number(NumberDataType::UInt64)),
TableField::new(
"total_columns",
TableDataType::Number(NumberDataType::UInt64),
),
TableField::new("engine", TableDataType::String),
TableField::new("engine_full", TableDataType::String),
TableField::new("cluster_by", TableDataType::String),
Expand Down Expand Up @@ -587,6 +591,10 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
.iter()
.map(|v| v.get_table_info().ident.table_id)
.collect();
let total_columns: Vec<u64> = database_tables
.iter()
.map(|v| v.get_table_info().schema().fields().len() as u64)
.collect();
let engines: Vec<String> = database_tables
.iter()
.map(|v| v.engine().to_string())
Expand Down Expand Up @@ -678,6 +686,7 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
StringType::from_data(databases),
StringType::from_data(names),
UInt64Type::from_data(table_id),
UInt64Type::from_data(total_columns),
StringType::from_data(engines),
StringType::from_data(engines_full),
StringType::from_data(cluster_bys),
Expand Down

0 comments on commit fcadc3d

Please sign in to comment.