This is an automated email from the ASF dual-hosted git repository. JingsongLi pushed a commit to branch release-2.0 in repository https://gitbox.apache.org/repos/asf/paimon.git
commit f812c1b8b56edfb319ec4f9e65df0acb52740edf Author: XiaoHongbo <[email protected]> AuthorDate: Sat Aug 1 18:47:03 2026 +0800 [core] Fix error classification for invalid bucket key (#8974) --- .../main/java/org/apache/paimon/schema/SchemaValidation.java | 2 +- .../java/org/apache/paimon/schema/SchemaValidationTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/paimon-core/src/main/java/org/apache/paimon/schema/SchemaValidation.java b/paimon-core/src/main/java/org/apache/paimon/schema/SchemaValidation.java index 8c058def52..7b9dead77c 100644 --- a/paimon-core/src/main/java/org/apache/paimon/schema/SchemaValidation.java +++ b/paimon-core/src/main/java/org/apache/paimon/schema/SchemaValidation.java @@ -1197,7 +1197,7 @@ public class SchemaValidation { int bucket = options.bucket(); if (bucket == -1) { if (options.toMap().get(BUCKET_KEY.key()) != null) { - throw new RuntimeException( + throw new IllegalArgumentException( "Cannot define 'bucket-key' with bucket = -1, please remove the 'bucket-key' setting or specify a bucket number."); } diff --git a/paimon-core/src/test/java/org/apache/paimon/schema/SchemaValidationTest.java b/paimon-core/src/test/java/org/apache/paimon/schema/SchemaValidationTest.java index ddc904978f..26294112f6 100644 --- a/paimon-core/src/test/java/org/apache/paimon/schema/SchemaValidationTest.java +++ b/paimon-core/src/test/java/org/apache/paimon/schema/SchemaValidationTest.java @@ -1594,6 +1594,17 @@ class SchemaValidationTest { .hasMessageContaining("bucket-key"); } + @Test + public void testBucketKeyWithDynamicBucket() { + Map<String, String> options = new HashMap<>(); + options.put(CoreOptions.BUCKET_KEY.key(), "f1"); + + assertThatThrownBy(() -> validateTableSchemaExec(options)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage( + "Cannot define 'bucket-key' with bucket = -1, please remove the 'bucket-key' setting or specify a bucket number."); + } + @Test public void testMergeOnReadIgnoredWhenDvDisabled() { Map<String, String> options = new HashMap<>();
