diff --git a/src/Dictionaries/getDictionaryConfigurationFromAST.cpp b/src/Dictionaries/getDictionaryConfigurationFromAST.cpp index 4868413dabd..6174cf5da46 100644 --- a/src/Dictionaries/getDictionaryConfigurationFromAST.cpp +++ b/src/Dictionaries/getDictionaryConfigurationFromAST.cpp @@ -623,20 +623,21 @@ getInfoIfClickHouseDictionarySource(DictionaryConfigurationPtr & config, Context { ClickHouseDictionarySourceInfo info; - String host = config->getString("dictionary.source.clickhouse.host", ""); - UInt16 port = config->getUInt("dictionary.source.clickhouse.port", 0); + bool secure = config->getBool("dictionary.source.clickhouse.secure", false); + UInt16 default_port = secure ? global_context->getTCPPortSecure().value_or(0) : global_context->getTCPPort(); + + String host = config->getString("dictionary.source.clickhouse.host", "localhost"); + UInt16 port = config->getUInt("dictionary.source.clickhouse.port", default_port); String database = config->getString("dictionary.source.clickhouse.db", ""); String table = config->getString("dictionary.source.clickhouse.table", ""); - bool secure = config->getBool("dictionary.source.clickhouse.secure", false); - if (host.empty() || port == 0 || table.empty()) + if (table.empty()) return {}; info.table_name = {database, table}; try { - UInt16 default_port = secure ? global_context->getTCPPortSecure().value_or(0) : global_context->getTCPPort(); if (isLocalAddress({host, port}, default_port)) info.is_local = true; } diff --git a/tests/integration/test_backup_restore_new/test.py b/tests/integration/test_backup_restore_new/test.py index 54dd9e41d4b..90e8acc702d 100644 --- a/tests/integration/test_backup_restore_new/test.py +++ b/tests/integration/test_backup_restore_new/test.py @@ -1182,6 +1182,7 @@ def test_tables_dependency(): t6 = random_table_names[5] t7 = random_table_names[6] t8 = random_table_names[7] + t9 = random_table_names[8] # Create a materialized view and a dictionary with a local table as source. instance.query( @@ -1210,12 +1211,17 @@ def test_tables_dependency(): f"CREATE TABLE {t8} AS {t2} ENGINE = Buffer({t2.split('.')[0]}, {t2.split('.')[1]}, 16, 10, 100, 10000, 1000000, 10000000, 100000000)" ) + instance.query( + f"CREATE DICTIONARY {t9} (x Int64, y String) PRIMARY KEY x SOURCE(CLICKHOUSE(TABLE '{t1.split('.')[1]}' DB '{t1.split('.')[0]}')) LAYOUT(FLAT()) LIFETIME(9)" + ) + # Make backup. backup_name = new_backup_name() instance.query(f"BACKUP DATABASE test, DATABASE test2 TO {backup_name}") # Drop everything in reversive order. def drop(): + instance.query(f"DROP DICTIONARY {t9}") instance.query(f"DROP TABLE {t8} NO DELAY") instance.query(f"DROP TABLE {t7} NO DELAY") instance.query(f"DROP TABLE {t6} NO DELAY") @@ -1235,7 +1241,7 @@ def test_tables_dependency(): # Check everything is restored. assert instance.query( "SELECT concat(database, '.', name) AS c FROM system.tables WHERE database IN ['test', 'test2'] ORDER BY c" - ) == TSV(sorted([t1, t2, t3, t4, t5, t6, t7, t8])) + ) == TSV(sorted([t1, t2, t3, t4, t5, t6, t7, t8, t9])) # Check logs. instance.query("SYSTEM FLUSH LOGS") @@ -1251,6 +1257,7 @@ def test_tables_dependency(): f"Table {t6} has 1 dependencies: {t4} (level 2)", f"Table {t7} has 1 dependencies: {t6} (level 3)", f"Table {t8} has 1 dependencies: {t2} (level 1)", + f"Table {t9} has 1 dependencies: {t1} (level 1)", ] for expect in expect_in_logs: assert any(