From aef499cf64593c8fa88fc5fcd97984b677bbf8ad Mon Sep 17 00:00:00 2001 From: Hongshun Wang Date: Wed, 18 Mar 2026 15:26:25 +0800 Subject: [PATCH 1/2] [server] return all invalid option in err msg of InvalidAlterTableException. --- .../client/table/LakeEnableTableITCase.java | 3 +- .../flink/catalog/FlinkCatalogITCase.java | 28 ++++++------- .../utils/TableDescriptorValidation.java | 39 ++++++++++++------- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/fluss-client/src/test/java/org/apache/fluss/client/table/LakeEnableTableITCase.java b/fluss-client/src/test/java/org/apache/fluss/client/table/LakeEnableTableITCase.java index d1d663d1b9..c06f18b644 100644 --- a/fluss-client/src/test/java/org/apache/fluss/client/table/LakeEnableTableITCase.java +++ b/fluss-client/src/test/java/org/apache/fluss/client/table/LakeEnableTableITCase.java @@ -108,8 +108,7 @@ void testCannotEnableDatalakeForTableCreatedBeforeClusterEnabledDatalake() throw .cause() .isInstanceOf(InvalidAlterTableException.class) .hasMessageContaining( - "The option 'table.datalake.enabled' cannot be altered for tables that were" - + " created before the Fluss cluster enabled datalake."); + "The following options cannot be altered for tables that were created before the Fluss cluster enabled datalake: table.datalake.enabled."); } @Test diff --git a/fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/catalog/FlinkCatalogITCase.java b/fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/catalog/FlinkCatalogITCase.java index af1e2eaaa3..ead9c8438a 100644 --- a/fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/catalog/FlinkCatalogITCase.java +++ b/fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/catalog/FlinkCatalogITCase.java @@ -249,45 +249,39 @@ void testAlterTableConfig() throws Exception { // alter table set an unsupported modification option should throw exception String unSupportedDml1 = - "alter table test_alter_table_append_only set ('table.auto-partition.enabled' = 'true')"; + "alter table test_alter_table_append_only set ('table.auto-partition.enabled' = 'true', 'table.kv.format' = 'indexed')"; assertThatThrownBy(() -> tEnv.executeSql(unSupportedDml1)) .rootCause() .isInstanceOf(InvalidAlterTableException.class) - .hasMessage( - "The option 'table.auto-partition.enabled' is not supported to alter yet."); + .hasMessageContaining("The following options are not supported to alter yet:") + .hasMessageContaining("table.kv.format") + .hasMessageContaining(" table.auto-partition.enabled"); String unSupportedDml2 = - "alter table test_alter_table_append_only set ('k1' = 'v1', 'table.kv.format' = 'indexed')"; - assertThatThrownBy(() -> tEnv.executeSql(unSupportedDml2)) - .rootCause() - .isInstanceOf(InvalidAlterTableException.class) - .hasMessage("The option 'table.kv.format' is not supported to alter yet."); - - String unSupportedDml3 = "alter table test_alter_table_append_only set ('bucket.num' = '1000')"; - assertThatThrownBy(() -> tEnv.executeSql(unSupportedDml3)) + assertThatThrownBy(() -> tEnv.executeSql(unSupportedDml2)) .rootCause() .isInstanceOf(CatalogException.class) .hasMessage("The option 'bucket.num' is not supported to alter yet."); - String unSupportedDml4 = + String unSupportedDml3 = "alter table test_alter_table_append_only set ('bucket.key' = 'a')"; - assertThatThrownBy(() -> tEnv.executeSql(unSupportedDml4)) + assertThatThrownBy(() -> tEnv.executeSql(unSupportedDml3)) .rootCause() .isInstanceOf(CatalogException.class) .hasMessage("The option 'bucket.key' is not supported to alter yet."); - String unSupportedDml5 = + String unSupportedDml4 = "alter table test_alter_table_append_only reset ('bootstrap.servers')"; - assertThatThrownBy(() -> tEnv.executeSql(unSupportedDml5)) + assertThatThrownBy(() -> tEnv.executeSql(unSupportedDml4)) .rootCause() .isInstanceOf(CatalogException.class) .hasMessage("The option 'bootstrap.servers' is not supported to alter yet."); - String unSupportedDml6 = + String unSupportedDml5 = "alter table test_alter_table_append_only set ('auto-increment.fields' = 'b')"; - assertThatThrownBy(() -> tEnv.executeSql(unSupportedDml6)) + assertThatThrownBy(() -> tEnv.executeSql(unSupportedDml5)) .rootCause() .isInstanceOf(CatalogException.class) .hasMessage("The option 'auto-increment.fields' is not supported to alter yet."); diff --git a/fluss-server/src/main/java/org/apache/fluss/server/utils/TableDescriptorValidation.java b/fluss-server/src/main/java/org/apache/fluss/server/utils/TableDescriptorValidation.java index d3bd94cd76..f749fc559d 100644 --- a/fluss-server/src/main/java/org/apache/fluss/server/utils/TableDescriptorValidation.java +++ b/fluss-server/src/main/java/org/apache/fluss/server/utils/TableDescriptorValidation.java @@ -123,22 +123,31 @@ public static void validateTableDescriptor(TableDescriptor tableDescriptor, int public static void validateAlterTableProperties( TableInfo currentTable, Set tableKeysToChange) { TableConfig currentConfig = currentTable.getTableConfig(); - tableKeysToChange.forEach( - k -> { - if (isTableStorageConfig(k) && !isAlterableTableOption(k)) { - throw new InvalidAlterTableException( - "The option '" + k + "' is not supported to alter yet."); - } - if (!currentConfig.getDataLakeFormat().isPresent() - && ConfigOptions.TABLE_DATALAKE_ENABLED.key().equals(k)) { - throw new InvalidAlterTableException( - String.format( - "The option '%s' cannot be altered for tables that were" - + " created before the Fluss cluster enabled datalake.", - ConfigOptions.TABLE_DATALAKE_ENABLED.key())); - } - }); + List unsupportedKeys = + tableKeysToChange.stream() + .filter(k -> isTableStorageConfig(k) && !isAlterableTableOption(k)) + .collect(Collectors.toList()); + if (!unsupportedKeys.isEmpty()) { + throw new InvalidAlterTableException( + String.format( + "The following options are not supported to alter yet: %s.", + String.join(", ", unsupportedKeys))); + } + + if (!currentConfig.getDataLakeFormat().isPresent()) { + List datalakeKeys = + tableKeysToChange.stream() + .filter(k -> k.startsWith("table.datalake.")) + .collect(Collectors.toList()); + if (!datalakeKeys.isEmpty()) { + throw new InvalidAlterTableException( + String.format( + "The following options cannot be altered for tables that were" + + " created before the Fluss cluster enabled datalake: %s.", + String.join(", ", datalakeKeys))); + } + } } private static void checkSystemColumns(RowType schema) { From ab4fa6a655aad5b97a687f2c0ca57d7908cf0a52 Mon Sep 17 00:00:00 2001 From: Hongshun Wang Date: Fri, 20 Mar 2026 14:18:41 +0800 Subject: [PATCH 2/2] add quote --- .../apache/fluss/client/table/LakeEnableTableITCase.java | 2 +- .../apache/fluss/flink/catalog/FlinkCatalogITCase.java | 2 +- .../fluss/server/utils/TableDescriptorValidation.java | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fluss-client/src/test/java/org/apache/fluss/client/table/LakeEnableTableITCase.java b/fluss-client/src/test/java/org/apache/fluss/client/table/LakeEnableTableITCase.java index c06f18b644..f4488774e9 100644 --- a/fluss-client/src/test/java/org/apache/fluss/client/table/LakeEnableTableITCase.java +++ b/fluss-client/src/test/java/org/apache/fluss/client/table/LakeEnableTableITCase.java @@ -108,7 +108,7 @@ void testCannotEnableDatalakeForTableCreatedBeforeClusterEnabledDatalake() throw .cause() .isInstanceOf(InvalidAlterTableException.class) .hasMessageContaining( - "The following options cannot be altered for tables that were created before the Fluss cluster enabled datalake: table.datalake.enabled."); + "The following options cannot be altered for tables that were created before the Fluss cluster enabled datalake: 'table.datalake.enabled'."); } @Test diff --git a/fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/catalog/FlinkCatalogITCase.java b/fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/catalog/FlinkCatalogITCase.java index ead9c8438a..90e9c23a06 100644 --- a/fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/catalog/FlinkCatalogITCase.java +++ b/fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/catalog/FlinkCatalogITCase.java @@ -256,7 +256,7 @@ void testAlterTableConfig() throws Exception { .isInstanceOf(InvalidAlterTableException.class) .hasMessageContaining("The following options are not supported to alter yet:") .hasMessageContaining("table.kv.format") - .hasMessageContaining(" table.auto-partition.enabled"); + .hasMessageContaining("table.auto-partition.enabled"); String unSupportedDml2 = "alter table test_alter_table_append_only set ('bucket.num' = '1000')"; diff --git a/fluss-server/src/main/java/org/apache/fluss/server/utils/TableDescriptorValidation.java b/fluss-server/src/main/java/org/apache/fluss/server/utils/TableDescriptorValidation.java index f749fc559d..14e4330d7c 100644 --- a/fluss-server/src/main/java/org/apache/fluss/server/utils/TableDescriptorValidation.java +++ b/fluss-server/src/main/java/org/apache/fluss/server/utils/TableDescriptorValidation.java @@ -132,7 +132,9 @@ public static void validateAlterTableProperties( throw new InvalidAlterTableException( String.format( "The following options are not supported to alter yet: %s.", - String.join(", ", unsupportedKeys))); + unsupportedKeys.stream() + .map(k -> "'" + k + "'") + .collect(Collectors.joining(", ")))); } if (!currentConfig.getDataLakeFormat().isPresent()) { @@ -145,7 +147,9 @@ public static void validateAlterTableProperties( String.format( "The following options cannot be altered for tables that were" + " created before the Fluss cluster enabled datalake: %s.", - String.join(", ", datalakeKeys))); + datalakeKeys.stream() + .map(k -> "'" + k + "'") + .collect(Collectors.joining(", ")))); } } }