From a450640175db598f2c1e6e91ba2ccf678284656b Mon Sep 17 00:00:00 2001 From: shuke <37901441+shuke987@users.noreply.github.com> Date: Fri, 3 Jul 2026 19:59:12 +0800 Subject: [PATCH] [fix](regression) Batch export_p0 generated VALUES inserts --- .../outfile/native/test_outfile_native.groovy | 17 ++++++++++------- .../suites/export_p0/test_outfile.groovy | 14 +++++++------- .../suites/export_p0/test_outfile_expr.groovy | 14 +++++++------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/regression-test/suites/export_p0/outfile/native/test_outfile_native.groovy b/regression-test/suites/export_p0/outfile/native/test_outfile_native.groovy index 334fc809b8861a..80edcdbee65b91 100644 --- a/regression-test/suites/export_p0/outfile/native/test_outfile_native.groovy +++ b/regression-test/suites/export_p0/outfile/native/test_outfile_native.groovy @@ -63,18 +63,21 @@ suite("test_outfile_native", "p0") { DISTRIBUTED BY HASH(id) PROPERTIES("replication_num" = "1"); """ - // Insert 10 rows of test data (the last row is all NULL) - StringBuilder sb = new StringBuilder() + // Avoid a single huge VALUES statement: Cloud P0 can spend over 120s + // preparing the plan fragment when all 10k rows are inserted at once. + List rows = [] int i = 1 for (; i < 10000; i ++) { - sb.append(""" - (${i}, '2024-01-01', '2024-01-01 00:00:00', 's${i}', ${i}, ${i % 128}, true, ${i}.${i}), + rows.add(""" + (${i}, '2024-01-01', '2024-01-01 00:00:00', 's${i}', ${i}, ${i % 128}, true, ${i}.${i}) """) } - sb.append(""" + rows.add(""" (${i}, '2024-01-01', '2024-01-01 00:00:00', NULL, NULL, NULL, NULL, NULL) """) - sql """ INSERT INTO ${tableName} VALUES ${sb.toString()} """ + rows.collate(500).each { batch -> + sql """ INSERT INTO ${tableName} VALUES ${batch.join(",")} """ + } // baseline: local table query result qt_select_default """ SELECT * FROM ${tableName} t ORDER BY id limit 10; """ @@ -97,4 +100,4 @@ suite("test_outfile_native", "p0") { } finally { try_sql("DROP TABLE IF EXISTS ${tableName}") } -} \ No newline at end of file +} diff --git a/regression-test/suites/export_p0/test_outfile.groovy b/regression-test/suites/export_p0/test_outfile.groovy index 35c5e0b681b115..87908fd691ddbf 100644 --- a/regression-test/suites/export_p0/test_outfile.groovy +++ b/regression-test/suites/export_p0/test_outfile.groovy @@ -86,19 +86,19 @@ suite("test_outfile") { ) DISTRIBUTED BY HASH(user_id) PROPERTIES("replication_num" = "1"); """ - StringBuilder sb = new StringBuilder() + List rows = [] int i = 1 for (; i < 1000; i ++) { - sb.append(""" - (${i}, '2017-10-01', '2017-10-01 00:00:00', '2017-10-01', '2017-10-01 00:00:00.111111', '2017-10-01 00:00:00.111111', '2017-10-01 00:00:00.111111', 'Beijing', ${i}, ${i % 128}, true, ${i}, ${i}, ${i}, ${i}.${i}, ${i}.${i}, 'char${i}', ${i}), + rows.add(""" + (${i}, '2017-10-01', '2017-10-01 00:00:00', '2017-10-01', '2017-10-01 00:00:00.111111', '2017-10-01 00:00:00.111111', '2017-10-01 00:00:00.111111', 'Beijing', ${i}, ${i % 128}, true, ${i}, ${i}, ${i}, ${i}.${i}, ${i}.${i}, 'char${i}', ${i}) """) } - sb.append(""" + rows.add(""" (${i}, '2017-10-01', '2017-10-01 00:00:00', '2017-10-01', '2017-10-01 00:00:00.111111', '2017-10-01 00:00:00.111111', '2017-10-01 00:00:00.111111', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) """) - sql """ INSERT INTO ${tableName} VALUES - ${sb.toString()} - """ + rows.collate(500).each { batch -> + sql """ INSERT INTO ${tableName} VALUES ${batch.join(",")} """ + } qt_select_default """ SELECT * FROM ${tableName} t ORDER BY user_id; """ // check outfile diff --git a/regression-test/suites/export_p0/test_outfile_expr.groovy b/regression-test/suites/export_p0/test_outfile_expr.groovy index 67c28f7739081d..fd4f1c786f8398 100644 --- a/regression-test/suites/export_p0/test_outfile_expr.groovy +++ b/regression-test/suites/export_p0/test_outfile_expr.groovy @@ -82,19 +82,19 @@ suite("test_outfile_expr") { ) DISTRIBUTED BY HASH(user_id) PROPERTIES("replication_num" = "1"); """ - StringBuilder sb = new StringBuilder() + List rows = [] int i = 1 for (; i < 1000; i ++) { - sb.append(""" - (${i}, '2017-10-01', '2017-10-01 00:00:00', 'Beijing', ${i}, ${i % 128}, true, ${i}, ${i}, ${i}, ${i}.${i}, ${i}.${i}, 'char${i}', ${i}), + rows.add(""" + (${i}, '2017-10-01', '2017-10-01 00:00:00', 'Beijing', ${i}, ${i % 128}, true, ${i}, ${i}, ${i}, ${i}.${i}, ${i}.${i}, 'char${i}', ${i}) """) } - sb.append(""" + rows.add(""" (${i}, '2017-10-01', '2017-10-01 00:00:00', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) """) - sql """ INSERT INTO ${tableName} VALUES - ${sb.toString()} - """ + rows.collate(500).each { batch -> + sql """ INSERT INTO ${tableName} VALUES ${batch.join(",")} """ + } qt_select_default """ SELECT user_id+1, age+sex, repeat(char_col, 10) FROM ${tableName} t ORDER BY user_id; """ // check outfile