Merge pull request #36439 from xiedeyantu/temp-table-improve

temporary table can show total rows and total bytes
This commit is contained in:
Antonio Andelic 2022-04-22 13:41:25 +02:00 committed by GitHub
commit 2e187e4b97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 3 deletions

View File

@ -244,10 +244,30 @@ protected:
if (columns_mask[src_index++])
res_columns[res_index++]->insert(table.second->getName());
/// Fill the rest columns with defaults
const auto & settings = context->getSettingsRef();
while (src_index < columns_mask.size())
if (columns_mask[src_index++])
{
// total_rows
if (src_index == 18 && columns_mask[src_index])
{
if (auto total_rows = table.second->totalRows(settings))
res_columns[res_index++]->insert(*total_rows);
else
res_columns[res_index++]->insertDefault();
}
// total_bytes
else if (src_index == 19 && columns_mask[src_index])
{
if (auto total_bytes = table.second->totalBytes(settings))
res_columns[res_index++]->insert(*total_bytes);
else
res_columns[res_index++]->insertDefault();
}
/// Fill the rest columns with defaults
else if (columns_mask[src_index])
res_columns[res_index++]->insertDefault();
src_index++;
}
}
}

View File

@ -2,7 +2,7 @@
1
1
1
t_00693 Memory 1 [] 1970-01-01 00:00:00 [] [] CREATE TEMPORARY TABLE t_00693 (`x` UInt8) ENGINE = Memory Memory \N \N
t_00693 Memory 1 [] 1970-01-01 00:00:00 [] [] CREATE TEMPORARY TABLE t_00693 (`x` UInt8) ENGINE = Memory Memory 0 0
1
1
1

View File

@ -0,0 +1 @@
02271_temporary_table_show_rows_bytes 1000 8192

View File

@ -0,0 +1,4 @@
-- NOTE: database = currentDatabase() is not mandatory
CREATE TEMPORARY TABLE 02271_temporary_table_show_rows_bytes (A Int64) Engine=Memory as SELECT * FROM numbers(1000);
SELECT database, name, total_rows, total_bytes FROM system.tables WHERE is_temporary AND name = '02271_temporary_table_show_rows_bytes';