Skip to content

Commit 16d17a4

Browse files
alexey-milovidovEnmk
authored andcommitted
Merge pull request ClickHouse#72304 from ClickHouse/fix_postgres_utility
Fix check in `test_postgresql_replica_database_engine_2`
1 parent 9eab34f commit 16d17a4

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

tests/integration/helpers/postgres_utility.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,22 @@ def assert_nested_table_is_created(
342342
table = schema_name + "." + table_name
343343

344344
print(f"Checking table {table} exists in {materialized_database}")
345-
database_tables = instance.query(f"SHOW TABLES FROM `{materialized_database}`")
346345

347-
while table not in database_tables:
348-
time.sleep(0.2)
349-
database_tables = instance.query(f"SHOW TABLES FROM `{materialized_database}`")
346+
# Check based on `system.tables` is not enough, because tables appear there before they are loaded.
347+
# It may lead to error `Unknown table expression identifier...`
348+
while True:
349+
try:
350+
instance.query(
351+
f"SELECT * FROM `{materialized_database}`.`{table}` LIMIT 1 FORMAT Null"
352+
)
353+
break
354+
except Exception:
355+
time.sleep(0.2)
356+
continue
350357

358+
database_tables = instance.query(
359+
f"SHOW TABLES FROM `{materialized_database}` WHERE name = '{table}'"
360+
)
351361
assert table in database_tables
352362

353363

0 commit comments

Comments
 (0)