From 78a5aed8df6badbd0ba121a73b80af4b484a8723 Mon Sep 17 00:00:00 2001 From: airborne12 Date: Thu, 31 Oct 2024 19:32:25 +0800 Subject: [PATCH] [Test](count on index) add statistics check for unique table (#42982) ## Proposed changes analyze unique table and wait for statistic upload --- .../test_count_on_index.groovy | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/regression-test/suites/inverted_index_p0/test_count_on_index.groovy b/regression-test/suites/inverted_index_p0/test_count_on_index.groovy index c0e7e6845d202b..89d1e8f93b25ea 100644 --- a/regression-test/suites/inverted_index_p0/test_count_on_index.groovy +++ b/regression-test/suites/inverted_index_p0/test_count_on_index.groovy @@ -146,30 +146,38 @@ suite("test_count_on_index_httplogs", "p0") { sql """set enable_fallback_to_original_planner=false;""" sql """analyze table ${testTable_dup} with sync"""; // case1: test duplicate table - def maxRetries = 3 - def attempt = 0 - def success = false + def executeSqlWithRetry = { String sqlQuery, int maxRetries = 3, int waitSeconds = 1 -> + def attempt = 0 + def success = false - while (attempt < maxRetries && !success) { - try { - explain { - sleep(10000) - sql("select COUNT() from ${testTable_dup}") - notContains("cardinality=0") - } - success = true - } catch (Exception e) { - attempt++ - log.error("Attempt ${attempt} failed: ${e.message}") - if (attempt < maxRetries) { - log.info("Retrying... (${attempt + 1}/${maxRetries})") - sleep(1000) - } else { - log.error("All ${maxRetries} attempts failed.") - throw e + while (attempt < maxRetries && !success) { + try { + explain { + // Wait for BE to report every partition's row count + sleep(10000) + sql(sqlQuery) + notContains("cardinality=0") + } + success = true + } catch (Exception e) { + attempt++ + log.error("Attempt ${attempt} failed: ${e.message}") + if (attempt < maxRetries) { + log.info("Retrying... (${attempt + 1}/${maxRetries}) after ${waitSeconds} second(s).") + sleep(waitSeconds * 1000) + } else { + log.error("All ${maxRetries} attempts failed.") + throw e + } } } } + // make sure row count stats is not 0 for duplicate table + executeSqlWithRetry("SELECT COUNT() FROM ${testTable_dup}") + // make sure row count stats is not 0 for unique table + sql """analyze table ${testTable_unique} with sync"""; + executeSqlWithRetry("SELECT COUNT() FROM ${testTable_unique}") + explain { sql("select COUNT() from ${testTable_dup} where request match 'GET'") contains "pushAggOp=COUNT_ON_INDEX"