Merge pull request #61479 from wudanzy/61220_fix_read_system_parts

Fix bug when reading system.parts using UUID (issue 61220).
This commit is contained in:
János Benjamin Antal 2024-03-21 14:43:29 +01:00 committed by GitHub
commit 1944162088
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 2 deletions

View File

@ -189,7 +189,7 @@ StoragesInfoStream::StoragesInfoStream(const ActionsDAG::Node * predicate, Conte
block_to_filter.insert(ColumnWithTypeAndName(std::move(table_column_mut), std::make_shared<DataTypeString>(), "table")); block_to_filter.insert(ColumnWithTypeAndName(std::move(table_column_mut), std::make_shared<DataTypeString>(), "table"));
block_to_filter.insert(ColumnWithTypeAndName(std::move(engine_column_mut), std::make_shared<DataTypeString>(), "engine")); block_to_filter.insert(ColumnWithTypeAndName(std::move(engine_column_mut), std::make_shared<DataTypeString>(), "engine"));
block_to_filter.insert(ColumnWithTypeAndName(std::move(active_column_mut), std::make_shared<DataTypeUInt8>(), "active")); block_to_filter.insert(ColumnWithTypeAndName(std::move(active_column_mut), std::make_shared<DataTypeUInt8>(), "active"));
block_to_filter.insert(ColumnWithTypeAndName(std::move(storage_uuid_column_mut), std::make_shared<DataTypeUUID>(), "uuid")); block_to_filter.insert(ColumnWithTypeAndName(std::move(storage_uuid_column_mut), std::make_shared<DataTypeUUID>(), "storage_uuid"));
if (rows) if (rows)
{ {
@ -201,7 +201,7 @@ StoragesInfoStream::StoragesInfoStream(const ActionsDAG::Node * predicate, Conte
database_column = block_to_filter.getByName("database").column; database_column = block_to_filter.getByName("database").column;
table_column = block_to_filter.getByName("table").column; table_column = block_to_filter.getByName("table").column;
active_column = block_to_filter.getByName("active").column; active_column = block_to_filter.getByName("active").column;
storage_uuid_column = block_to_filter.getByName("uuid").column; storage_uuid_column = block_to_filter.getByName("storage_uuid").column;
} }
class ReadFromSystemPartsBase : public SourceStepWithFilter class ReadFromSystemPartsBase : public SourceStepWithFilter

View File

@ -0,0 +1,10 @@
00000000-0000-0000-0000-000000000000 1231_1_1_0
00000000-0000-0000-0000-000000000000 6666_2_2_0
00000000-0000-0000-0000-000000000000 1231_1_1_0 users
00000000-0000-0000-0000-000000000000 6666_2_2_0 users
00000000-0000-0000-0000-000000000000 1231_1_1_0 users uid
00000000-0000-0000-0000-000000000000 1231_1_1_0 users name
00000000-0000-0000-0000-000000000000 1231_1_1_0 users age
00000000-0000-0000-0000-000000000000 6666_2_2_0 users uid
00000000-0000-0000-0000-000000000000 6666_2_2_0 users name
00000000-0000-0000-0000-000000000000 6666_2_2_0 users age

View File

@ -0,0 +1,11 @@
DROP TABLE IF EXISTS users;
CREATE TABLE users (uid Int16, name String, age Int16) ENGINE=MergeTree ORDER BY uid PARTITION BY uid;
INSERT INTO users VALUES (1231, 'John', 33);
INSERT INTO users VALUES (6666, 'Ksenia', 48);
SELECT uuid, name from system.parts WHERE database = currentDatabase() AND table = 'users';
SELECT uuid, name, table from system.parts WHERE database = currentDatabase() AND table = 'users' AND uuid = '00000000-0000-0000-0000-000000000000';
SELECT uuid, name, table, column from system.parts_columns WHERE database = currentDatabase() AND table = 'users' AND uuid = '00000000-0000-0000-0000-000000000000';
DROP TABLE IF EXISTS users;