From 980c4b79d3456efd19836ab71840384d58241647 Mon Sep 17 00:00:00 2001 From: Socrates Date: Wed, 27 May 2026 19:01:13 +0800 Subject: [PATCH] [fix](regression) Make Iceberg rewrite where init script idempotent (#63673) `test_iceberg_rewrite_data_files_where_conditions` depends on three Iceberg tables created by the Spark bootstrap script `run21.sql`. The script used `CREATE TABLE IF NOT EXISTS` and then always inserted the test rows. If the table already exists or the bootstrap SQL is re-entered after partial execution, the insert statements append data to the existing table, so the regression case may fail before running `rewrite_data_files` because `COUNT(*)` is no longer the expected 30 rows. This PR makes the init SQL for this case idempotent by dropping and recreating the three test tables before inserting the fixed test data. --- .../create_preinstalled_scripts/iceberg/run21.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docker/thirdparties/docker-compose/iceberg/scripts/create_preinstalled_scripts/iceberg/run21.sql b/docker/thirdparties/docker-compose/iceberg/scripts/create_preinstalled_scripts/iceberg/run21.sql index e7873d468adae0..4af60fed6ba86d 100644 --- a/docker/thirdparties/docker-compose/iceberg/scripts/create_preinstalled_scripts/iceberg/run21.sql +++ b/docker/thirdparties/docker-compose/iceberg/scripts/create_preinstalled_scripts/iceberg/run21.sql @@ -8,7 +8,8 @@ use demo.test_db; -- ===================================================================================== -- Table 1: For baseline test (rewrite without WHERE condition) -CREATE TABLE IF NOT EXISTS test_rewrite_where_conditions_baseline ( +DROP TABLE IF EXISTS test_rewrite_where_conditions_baseline; +CREATE TABLE test_rewrite_where_conditions_baseline ( id BIGINT, name STRING, age INT, @@ -56,7 +57,8 @@ INSERT INTO test_rewrite_where_conditions_baseline VALUES (30, 'Dana', 49, 99000.0); -- Table 2: For test with WHERE condition matching subset (id >= 11 AND id <= 20) -CREATE TABLE IF NOT EXISTS test_rewrite_where_conditions_with_where ( +DROP TABLE IF EXISTS test_rewrite_where_conditions_with_where; +CREATE TABLE test_rewrite_where_conditions_with_where ( id BIGINT, name STRING, age INT, @@ -104,7 +106,8 @@ INSERT INTO test_rewrite_where_conditions_with_where VALUES (30, 'Dana', 49, 99000.0); -- Table 3: For test with WHERE condition matching no data (id = 99999) -CREATE TABLE IF NOT EXISTS test_rewrite_where_conditions_no_match ( +DROP TABLE IF EXISTS test_rewrite_where_conditions_no_match; +CREATE TABLE test_rewrite_where_conditions_no_match ( id BIGINT, name STRING, age INT,