From 0d2acf9eec0f86d3ecd57b1a3d7287348f6bbaa0 Mon Sep 17 00:00:00 2001 From: jsc0218 Date: Wed, 15 Nov 2023 20:30:36 +0000 Subject: [PATCH] Able to Filter Engine When Scanning System Tables --- src/Storages/System/StorageSystemTables.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Storages/System/StorageSystemTables.cpp b/src/Storages/System/StorageSystemTables.cpp index d888813f6ce..7162e662194 100644 --- a/src/Storages/System/StorageSystemTables.cpp +++ b/src/Storages/System/StorageSystemTables.cpp @@ -74,18 +74,24 @@ namespace ColumnPtr getFilteredDatabases(const SelectQueryInfo & query_info, ContextPtr context) { - MutableColumnPtr column = ColumnString::create(); + MutableColumnPtr database_column = ColumnString::create(); + MutableColumnPtr engine_column = ColumnString::create(); const auto databases = DatabaseCatalog::instance().getDatabases(); - for (const auto & database_name : databases | boost::adaptors::map_keys) + for (const auto & [database_name, database] : databases) { if (database_name == DatabaseCatalog::TEMPORARY_DATABASE) continue; /// We don't want to show the internal database for temporary tables in system.tables - column->insert(database_name); + database_column->insert(database_name); + engine_column->insert(database->getEngineName()); } - Block block { ColumnWithTypeAndName(std::move(column), std::make_shared(), "database") }; + Block block + { + ColumnWithTypeAndName(std::move(database_column), std::make_shared(), "database"), + ColumnWithTypeAndName(std::move(engine_column), std::make_shared(), "engine") + }; VirtualColumnUtils::filterBlockWithQuery(query_info.query, block, context); return block.getByPosition(0).column; }