diff --git a/src/Interpreters/InterpreterShowTablesQuery.cpp b/src/Interpreters/InterpreterShowTablesQuery.cpp index d8e01ecd722a..634fa9515f03 100644 --- a/src/Interpreters/InterpreterShowTablesQuery.cpp +++ b/src/Interpreters/InterpreterShowTablesQuery.cpp @@ -232,10 +232,10 @@ BlockIO InterpreterShowTablesQuery::execute() } auto rewritten_query = getRewrittenQuery(); String database = getContext()->resolveDatabase(query.getFrom()); - if (DatabaseCatalog::instance().isDatalakeCatalog(database)) + if (query.databases || DatabaseCatalog::instance().isDatalakeCatalog(database)) { auto context_copy = Context::createCopy(getContext()); - /// HACK To always show them in explicit "SHOW TABLES" queries + /// HACK To always show them in explicit "SHOW TABLES" and "SHOW DATABASES" queries context_copy->setSetting("show_data_lake_catalogs_in_system_tables", true); return executeQuery(rewritten_query, context_copy, QueryFlags{ .internal = true }).second; } diff --git a/tests/integration/test_database_glue/test.py b/tests/integration/test_database_glue/test.py index 7ba239484640..c53d1fe145ea 100644 --- a/tests/integration/test_database_glue/test.py +++ b/tests/integration/test_database_glue/test.py @@ -617,6 +617,8 @@ def test_system_tables(started_cluster): node.query(f"SELECT count() FROM {CATALOG_NAME}.`{namespace}.{table_name}`") ) + assert CATALOG_NAME in node.query("SHOW DATABASES") + assert table_name in node.query(f"SHOW TABLES FROM {CATALOG_NAME}") # system.tables assert int(node.query(f"SELECT count() FROM system.tables WHERE database = '{CATALOG_NAME}' and table ilike '%{root_namespace}%' SETTINGS show_data_lake_catalogs_in_system_tables = true").strip()) == 4 assert int(node.query(f"SELECT count() FROM system.tables WHERE database = '{CATALOG_NAME}' and table ilike '%{root_namespace}%'").strip()) == 0