Skip to content

Commit

Permalink
chore(query): add node column for processes table (databendlabs#13364)
Browse files Browse the repository at this point in the history
* chore(query) add node column for processes table

* chore(query) add node column for processes table
  • Loading branch information
zhang2014 authored Oct 21, 2023
1 parent a057943 commit 46d2e86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ DB.Table: 'system'.'columns', Table: columns-table_id:1, ver:0, Engine: SystemCo
| 'node' | 'system' | 'backtrace' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'node' | 'system' | 'caches' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'node' | 'system' | 'metrics' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'node' | 'system' | 'processes' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'node_id' | 'system' | 'query_log' | 'String' | 'VARCHAR' | '' | '' | 'NO' | '' |
| 'non_unique' | 'information_schema' | 'statistics' | 'NULL' | 'NULL' | '' | '' | 'NO' | '' |
| 'nullable' | 'information_schema' | 'columns' | 'Nullable(UInt8)' | 'TINYINT UNSIGNED' | '' | '' | 'YES' | '' |
Expand Down
6 changes: 6 additions & 0 deletions src/query/storages/system/src/processes_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ impl SyncSystemTable for ProcessesTable {
fn get_full_data(&self, ctx: Arc<dyn TableContext>) -> Result<DataBlock> {
let processes_info = ctx.get_processes_info();

let local_node = ctx.get_cluster().local_id.clone();

let mut nodes: Vec<Vec<u8>> = Vec::with_capacity(processes_info.len());
let mut processes_id = Vec::with_capacity(processes_info.len());
let mut processes_type = Vec::with_capacity(processes_info.len());
let mut processes_host = Vec::with_capacity(processes_info.len());
Expand All @@ -79,6 +82,7 @@ impl SyncSystemTable for ProcessesTable {
.unwrap_or(Duration::from_secs(0))
.as_secs();

nodes.push(local_node.clone().into_bytes());
processes_id.push(process_info.id.clone().into_bytes());
processes_type.push(process_info.typ.clone().into_bytes());
processes_state.push(process_info.state.to_string().into_bytes());
Expand Down Expand Up @@ -118,6 +122,7 @@ impl SyncSystemTable for ProcessesTable {
}

Ok(DataBlock::new_from_columns(vec![
StringType::from_data(nodes),
StringType::from_data(processes_id),
StringType::from_data(processes_type),
StringType::from_opt_data(processes_host),
Expand All @@ -140,6 +145,7 @@ impl SyncSystemTable for ProcessesTable {
impl ProcessesTable {
pub fn create(table_id: u64) -> Arc<dyn Table> {
let schema = TableSchemaRefExt::create(vec![
TableField::new("node", TableDataType::String),
TableField::new("id", TableDataType::String),
TableField::new("type", TableDataType::String),
TableField::new(
Expand Down

0 comments on commit 46d2e86

Please sign in to comment.