mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Add total_rows to the system.tables
This commit is contained in:
parent
b66f2efc9e
commit
2489481a46
@ -2,6 +2,7 @@
|
||||
#include <Columns/ColumnsNumber.h>
|
||||
#include <DataTypes/DataTypeString.h>
|
||||
#include <DataTypes/DataTypeDateTime.h>
|
||||
#include <DataTypes/DataTypeNullable.h>
|
||||
#include <DataStreams/OneBlockInputStream.h>
|
||||
#include <Storages/System/StorageSystemTables.h>
|
||||
#include <Storages/VirtualColumnUtils.h>
|
||||
@ -49,6 +50,7 @@ StorageSystemTables::StorageSystemTables(const std::string & name_)
|
||||
{"primary_key", std::make_shared<DataTypeString>()},
|
||||
{"sampling_key", std::make_shared<DataTypeString>()},
|
||||
{"storage_policy", std::make_shared<DataTypeString>()},
|
||||
{"total_rows", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeUInt64>())},
|
||||
}));
|
||||
}
|
||||
|
||||
@ -204,6 +206,10 @@ protected:
|
||||
// storage_policy
|
||||
if (columns_mask[src_index++])
|
||||
res_columns[res_index++]->insertDefault();
|
||||
|
||||
// total_rows
|
||||
if (columns_mask[src_index++])
|
||||
res_columns[res_index++]->insertDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,6 +385,16 @@ protected:
|
||||
else
|
||||
res_columns[res_index++]->insertDefault();
|
||||
}
|
||||
|
||||
if (columns_mask[src_index++])
|
||||
{
|
||||
assert(table != nullptr);
|
||||
auto total_rows = table->totalRows();
|
||||
if (total_rows)
|
||||
res_columns[res_index++]->insert(*total_rows);
|
||||
else
|
||||
res_columns[res_index++]->insertDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -934,6 +934,12 @@ This table contains the following columns (the column type is shown in brackets)
|
||||
- `sorting_key` (String) - The sorting key expression specified in the table.
|
||||
- `primary_key` (String) - The primary key expression specified in the table.
|
||||
- `sampling_key` (String) - The sampling key expression specified in the table.
|
||||
- `storage_policy` (String) - The storage policy:
|
||||
|
||||
- [MergeTree](table_engines/mergetree.md#table_engine-mergetree-multiple-volumes)
|
||||
- [Distributed](table_engines/distributed.md#distributed)
|
||||
|
||||
- `total_rows` (Nullable(UInt64)) - Total number of rows, if it is possible to quickly determine exact number of rows in the table, otherwise `Null` (including underying `Buffer` table).
|
||||
|
||||
The `system.tables` table is used in `SHOW TABLES` query implementation.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user