mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #11655 from ClickHouse/position-in-system-columns
Added column "position" to system.columns and "column_position" to system.parts_columns
This commit is contained in:
commit
561d4b5b01
@ -32,6 +32,7 @@ StorageSystemColumns::StorageSystemColumns(const std::string & name_)
|
||||
{ "table", std::make_shared<DataTypeString>() },
|
||||
{ "name", std::make_shared<DataTypeString>() },
|
||||
{ "type", std::make_shared<DataTypeString>() },
|
||||
{ "position", std::make_shared<DataTypeUInt64>() },
|
||||
{ "default_kind", std::make_shared<DataTypeString>() },
|
||||
{ "default_expression", std::make_shared<DataTypeString>() },
|
||||
{ "data_compressed_bytes", std::make_shared<DataTypeUInt64>() },
|
||||
@ -131,8 +132,10 @@ protected:
|
||||
|
||||
bool check_access_for_columns = check_access_for_tables && !access->isGranted(AccessType::SHOW_COLUMNS, database_name, table_name);
|
||||
|
||||
size_t position = 0;
|
||||
for (const auto & column : columns)
|
||||
{
|
||||
++position;
|
||||
if (check_access_for_columns && !access->isGranted(AccessType::SHOW_COLUMNS, database_name, table_name, column.name))
|
||||
continue;
|
||||
|
||||
@ -147,6 +150,8 @@ protected:
|
||||
res_columns[res_index++]->insert(column.name);
|
||||
if (columns_mask[src_index++])
|
||||
res_columns[res_index++]->insert(column.type->getName());
|
||||
if (columns_mask[src_index++])
|
||||
res_columns[res_index++]->insert(position);
|
||||
|
||||
if (column.default_desc.expression)
|
||||
{
|
||||
|
@ -49,6 +49,7 @@ StorageSystemPartsColumns::StorageSystemPartsColumns(const std::string & name_)
|
||||
|
||||
{"column", std::make_shared<DataTypeString>()},
|
||||
{"type", std::make_shared<DataTypeString>()},
|
||||
{"column_position", std::make_shared<DataTypeUInt64>()},
|
||||
{"default_kind", std::make_shared<DataTypeString>()},
|
||||
{"default_expression", std::make_shared<DataTypeString>()},
|
||||
{"column_bytes_on_disk", std::make_shared<DataTypeUInt64>()},
|
||||
@ -101,9 +102,10 @@ void StorageSystemPartsColumns::processNextStorage(MutableColumns & columns_, co
|
||||
|
||||
using State = IMergeTreeDataPart::State;
|
||||
|
||||
size_t column_position = 0;
|
||||
for (const auto & column : part->getColumns())
|
||||
|
||||
{
|
||||
++column_position;
|
||||
size_t j = 0;
|
||||
{
|
||||
WriteBufferFromOwnString out;
|
||||
@ -143,6 +145,7 @@ void StorageSystemPartsColumns::processNextStorage(MutableColumns & columns_, co
|
||||
|
||||
columns_[j++]->insert(column.name);
|
||||
columns_[j++]->insert(column.type->getName());
|
||||
columns_[j++]->insert(column_position);
|
||||
|
||||
auto column_info_it = columns_info.find(column.name);
|
||||
if (column_info_it != columns_info.end())
|
||||
|
@ -1 +1 @@
|
||||
default merge_ab x UInt8 0 0 0 0 0 0 0
|
||||
x
|
||||
|
@ -6,7 +6,7 @@ CREATE TABLE merge_a (x UInt8) ENGINE = StripeLog;
|
||||
CREATE TABLE merge_b (x UInt8) ENGINE = StripeLog;
|
||||
CREATE TABLE merge_ab AS merge(currentDatabase(), '^merge_[ab]$');
|
||||
|
||||
SELECT * FROM system.columns WHERE database = currentDatabase() AND table = 'merge_ab';
|
||||
SELECT name FROM system.columns WHERE database = currentDatabase() AND table = 'merge_ab';
|
||||
|
||||
DROP TABLE merge_a;
|
||||
DROP TABLE merge_b;
|
||||
|
@ -0,0 +1,6 @@
|
||||
x UInt8 1
|
||||
y String 2
|
||||
z Array(String) 3
|
||||
x UInt8 1
|
||||
y String 2
|
||||
z Array(String) 3
|
@ -0,0 +1,8 @@
|
||||
DROP TABLE IF EXISTS test;
|
||||
CREATE TABLE test (x UInt8, y String, z Array(String)) ENGINE = MergeTree ORDER BY tuple();
|
||||
INSERT INTO test (x) VALUES (1);
|
||||
|
||||
SELECT name, type, position FROM system.columns WHERE database = currentDatabase() AND table = 'test';
|
||||
SELECT column, type, column_position FROM system.parts_columns WHERE database = currentDatabase() AND table = 'test';
|
||||
|
||||
DROP TABLE test;
|
Loading…
Reference in New Issue
Block a user