From b3344558c1d708907c9b518dbd7b16700c83e014 Mon Sep 17 00:00:00 2001 From: Nikita Taranov Date: Fri, 22 Nov 2024 21:01:05 +0100 Subject: [PATCH] fix --- tests/integration/helpers/postgres_utility.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/integration/helpers/postgres_utility.py b/tests/integration/helpers/postgres_utility.py index ba6ec1fd66e..c6c8fc01211 100644 --- a/tests/integration/helpers/postgres_utility.py +++ b/tests/integration/helpers/postgres_utility.py @@ -343,16 +343,20 @@ def assert_nested_table_is_created( table = schema_name + "." + table_name print(f"Checking table {table} exists in {materialized_database}") + + # Check based on `system.tables` is not enough, because tables appear there before they are loaded. + # It may lead to error `Unknown table expression identifier...` + while True: + try: + instance.query(f"SELECT * FROM `{materialized_database}`.`{table}` LIMIT 1 FORMAT Null") + break + except Exception: + time.sleep(0.2) + continue + database_tables = instance.query( f"SHOW TABLES FROM `{materialized_database}` WHERE name = '{table}'" ) - - while table not in database_tables: - time.sleep(0.2) - database_tables = instance.query( - f"SHOW TABLES FROM `{materialized_database}` WHERE name = '{table}'" - ) - assert table in database_tables