This is an automated email from the ASF dual-hosted git repository. gavinchou pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push: new 83800fc2583 branch-3.0: [opt](schema_change) Fix null message when trying to alter forbidden table properties #46236 (#46379) 83800fc2583 is described below commit 83800fc2583464d2949a0847f99f23e7d5bc0a3d Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Sun Jan 5 11:41:50 2025 +0800 branch-3.0: [opt](schema_change) Fix null message when trying to alter forbidden table properties #46236 (#46379) Cherry-picked from #46236 Co-authored-by: Gavin Chou <ga...@selectdb.com> --- .../apache/doris/alter/SchemaChangeHandler.java | 43 +++++++++++++--------- .../cloud/alter/CloudSchemaChangeHandler.java | 36 ++++++++++++------ .../schema_change/test_alter_table_property.groovy | 14 +++++++ 3 files changed, 64 insertions(+), 29 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java index 949f4a866ac..884af89e026 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java @@ -2283,26 +2283,35 @@ public class SchemaChangeHandler extends AlterHandler { */ public void updateTableProperties(Database db, String tableName, Map<String, String> properties) throws UserException { - Preconditions.checkState(properties.containsKey(PropertyAnalyzer.PROPERTIES_INMEMORY) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_STORAGE_POLICY) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_IS_BEING_SYNCED) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_COMPACTION_POLICY) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_GOAL_SIZE_MBYTES) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_FILE_COUNT_THRESHOLD) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_TIME_THRESHOLD_SECONDS) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_GROUP_COMMIT_INTERVAL_MS) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_GROUP_COMMIT_DATA_BYTES) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_ENABLE_MOW_LIGHT_DELETE) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_ENABLE_SINGLE_REPLICA_COMPACTION) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_DISABLE_AUTO_COMPACTION) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_SKIP_WRITE_INDEX_ON_LOAD) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_EMPTY_ROWSETS_THRESHOLD) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_LEVEL_THRESHOLD) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_AUTO_ANALYZE_POLICY)); + final Set<String> allowedProps = new HashSet<String>() { + { + add(PropertyAnalyzer.PROPERTIES_INMEMORY); + add(PropertyAnalyzer.PROPERTIES_STORAGE_POLICY); + add(PropertyAnalyzer.PROPERTIES_IS_BEING_SYNCED); + add(PropertyAnalyzer.PROPERTIES_COMPACTION_POLICY); + add(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_GOAL_SIZE_MBYTES); + add(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_FILE_COUNT_THRESHOLD); + add(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_TIME_THRESHOLD_SECONDS); + add(PropertyAnalyzer.PROPERTIES_GROUP_COMMIT_INTERVAL_MS); + add(PropertyAnalyzer.PROPERTIES_GROUP_COMMIT_DATA_BYTES); + add(PropertyAnalyzer.PROPERTIES_ENABLE_MOW_LIGHT_DELETE); + add(PropertyAnalyzer.PROPERTIES_ENABLE_SINGLE_REPLICA_COMPACTION); + add(PropertyAnalyzer.PROPERTIES_DISABLE_AUTO_COMPACTION); + add(PropertyAnalyzer.PROPERTIES_SKIP_WRITE_INDEX_ON_LOAD); + add(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_EMPTY_ROWSETS_THRESHOLD); + add(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_LEVEL_THRESHOLD); + add(PropertyAnalyzer.PROPERTIES_AUTO_ANALYZE_POLICY); + } + }; + List<String> notAllowedProps = properties.keySet().stream().filter(s -> !allowedProps.contains(s)) + .collect(Collectors.toList()); + if (!notAllowedProps.isEmpty()) { + throw new UserException("modifying property " + notAllowedProps + " is forbidden"); + } Env.getCurrentEnv().getAlterInstance().checkNoForceProperty(properties); List<Partition> partitions = Lists.newArrayList(); - OlapTable olapTable = (OlapTable) db.getTableOrMetaException(tableName, Table.TableType.OLAP); + OlapTable olapTable = (OlapTable) db.getTableOrMetaException(tableName, TableType.OLAP); boolean enableUniqueKeyMergeOnWrite = false; olapTable.readLock(); try { diff --git a/fe/fe-core/src/main/java/org/apache/doris/cloud/alter/CloudSchemaChangeHandler.java b/fe/fe-core/src/main/java/org/apache/doris/cloud/alter/CloudSchemaChangeHandler.java index fa3bb96014c..cc6af7b2c12 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/cloud/alter/CloudSchemaChangeHandler.java +++ b/fe/fe-core/src/main/java/org/apache/doris/cloud/alter/CloudSchemaChangeHandler.java @@ -40,8 +40,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; public class CloudSchemaChangeHandler extends SchemaChangeHandler { private static final Logger LOG = LogManager.getLogger(CloudSchemaChangeHandler.class); @@ -90,18 +93,27 @@ public class CloudSchemaChangeHandler extends SchemaChangeHandler { @Override public void updateTableProperties(Database db, String tableName, Map<String, String> properties) throws UserException { - Preconditions.checkState(properties.containsKey(PropertyAnalyzer.PROPERTIES_GROUP_COMMIT_INTERVAL_MS) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_GROUP_COMMIT_DATA_BYTES) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_FILE_CACHE_TTL_SECONDS) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_COMPACTION_POLICY) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_GOAL_SIZE_MBYTES) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_FILE_COUNT_THRESHOLD) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_TIME_THRESHOLD_SECONDS) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_EMPTY_ROWSETS_THRESHOLD) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_LEVEL_THRESHOLD) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_DISABLE_AUTO_COMPACTION) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_ENABLE_MOW_LIGHT_DELETE) - || properties.containsKey(PropertyAnalyzer.PROPERTIES_AUTO_ANALYZE_POLICY)); + final Set<String> allowedProps = new HashSet<String>() { + { + add(PropertyAnalyzer.PROPERTIES_GROUP_COMMIT_INTERVAL_MS); + add(PropertyAnalyzer.PROPERTIES_GROUP_COMMIT_DATA_BYTES); + add(PropertyAnalyzer.PROPERTIES_FILE_CACHE_TTL_SECONDS); + add(PropertyAnalyzer.PROPERTIES_COMPACTION_POLICY); + add(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_GOAL_SIZE_MBYTES); + add(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_FILE_COUNT_THRESHOLD); + add(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_TIME_THRESHOLD_SECONDS); + add(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_EMPTY_ROWSETS_THRESHOLD); + add(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_LEVEL_THRESHOLD); + add(PropertyAnalyzer.PROPERTIES_DISABLE_AUTO_COMPACTION); + add(PropertyAnalyzer.PROPERTIES_ENABLE_MOW_LIGHT_DELETE); + add(PropertyAnalyzer.PROPERTIES_AUTO_ANALYZE_POLICY); + } + }; + List<String> notAllowedProps = properties.keySet().stream().filter(s -> !allowedProps.contains(s)) + .collect(Collectors.toList()); + if (!notAllowedProps.isEmpty()) { + throw new UserException("modifying property " + notAllowedProps + " is forbidden"); + } if (properties.size() != 1) { throw new UserException("Can only set one table property at a time"); diff --git a/regression-test/suites/schema_change/test_alter_table_property.groovy b/regression-test/suites/schema_change/test_alter_table_property.groovy index 5a6e65461a8..3d94d88c8dc 100644 --- a/regression-test/suites/schema_change/test_alter_table_property.groovy +++ b/regression-test/suites/schema_change/test_alter_table_property.groovy @@ -46,6 +46,20 @@ suite("test_alter_table_property") { def showResult2 = sql """show create table ${tableName}""" logger.info("${showResult2}") assertTrue(showResult2.toString().containsIgnoreCase('"enable_single_replica_compaction" = "true"')) + + test { + sql """ + alter table ${tableName} set ("file_cache_ttl_seconds" = "86400") + """ + exception "modifying property [file_cache_ttl_seconds] is forbidden" + } + } else { + test { + sql """ + alter table ${tableName} set ("enable_single_replica_compaction" = "true") + """ + exception "modifying property [enable_single_replica_compaction] is forbidden" + } } assertTrue(showResult1.toString().containsIgnoreCase('"disable_auto_compaction" = "false"')) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org