This is an automated email from the ASF dual-hosted git repository.
zhangchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 44f093dc463 [Opt](mow) Forbid time_series compaction policy on unique
table (#49905)
44f093dc463 is described below
commit 44f093dc463208c0f955570ee4f11ace52a37075
Author: bobhan1 <[email protected]>
AuthorDate: Thu Apr 17 14:22:17 2025 +0800
[Opt](mow) Forbid time_series compaction policy on unique table (#49905)
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [x] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [x] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [x] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
---
.../apache/doris/alter/SchemaChangeHandler.java | 5 ++
.../cloud/alter/CloudSchemaChangeHandler.java | 5 ++
.../apache/doris/common/util/PropertyAnalyzer.java | 6 +-
.../apache/doris/datasource/InternalCatalog.java | 2 +-
.../decimalv3/test_decimalv3_overflow.groovy | 1 -
.../test_mow_time_series_compaction.groovy | 81 ++++++++++++++++++++++
6 files changed, 97 insertions(+), 3 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 db9a68b3401..a235fd76182 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
@@ -2379,6 +2379,11 @@ public class SchemaChangeHandler extends AlterHandler {
+ " or " +
PropertyAnalyzer.SIZE_BASED_COMPACTION_POLICY);
}
+ if (compactionPolicy != null &&
compactionPolicy.equals(PropertyAnalyzer.TIME_SERIES_COMPACTION_POLICY)
+ && olapTable.getKeysType() == KeysType.UNIQUE_KEYS) {
+ throw new UserException("Time series compaction policy is not
supported for unique key table");
+ }
+
Map<String, Long> timeSeriesCompactionConfig = new HashMap<>();
if
(properties.containsKey(PropertyAnalyzer.PROPERTIES_TIME_SERIES_COMPACTION_GOAL_SIZE_MBYTES))
{
timeSeriesCompactionConfig
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 cc6af7b2c12..9277982b573 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
@@ -20,6 +20,7 @@ package org.apache.doris.cloud.alter;
import org.apache.doris.alter.SchemaChangeHandler;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.KeysType;
import org.apache.doris.catalog.MaterializedIndex;
import org.apache.doris.catalog.MaterializedIndex.IndexExtState;
import org.apache.doris.catalog.OlapTable;
@@ -179,6 +180,10 @@ public class CloudSchemaChangeHandler extends
SchemaChangeHandler {
+ PropertyAnalyzer.TIME_SERIES_COMPACTION_POLICY
+ " or " +
PropertyAnalyzer.SIZE_BASED_COMPACTION_POLICY);
}
+ if (compactionPolicy != null &&
compactionPolicy.equals(PropertyAnalyzer.TIME_SERIES_COMPACTION_POLICY)
+ && olapTable.getKeysType() == KeysType.UNIQUE_KEYS) {
+ throw new UserException("Time series compaction policy is not
supported for unique key table");
+ }
olapTable.readLock();
try {
if (compactionPolicy == olapTable.getCompactionPolicy()) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
index dfb0e72b58b..74a0a1d9258 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
@@ -898,7 +898,8 @@ public class PropertyAnalyzer {
+ " must be `true` or `false`");
}
- public static String analyzeCompactionPolicy(Map<String, String>
properties) throws AnalysisException {
+ public static String analyzeCompactionPolicy(Map<String, String>
properties, KeysType keysType)
+ throws AnalysisException {
if (properties == null || properties.isEmpty()) {
return SIZE_BASED_COMPACTION_POLICY;
}
@@ -913,6 +914,9 @@ public class PropertyAnalyzer {
}
}
+ if (keysType == KeysType.UNIQUE_KEYS &&
compactionPolicy.equals(TIME_SERIES_COMPACTION_POLICY)) {
+ throw new AnalysisException("Time series compaction policy is not
supported for unique key table");
+ }
return compactionPolicy;
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
index 6339e4a91f9..0c176e6b796 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
@@ -2592,7 +2592,7 @@ public class InternalCatalog implements
CatalogIf<Database> {
// set compaction policy
String compactionPolicy =
PropertyAnalyzer.SIZE_BASED_COMPACTION_POLICY;
try {
- compactionPolicy =
PropertyAnalyzer.analyzeCompactionPolicy(properties);
+ compactionPolicy =
PropertyAnalyzer.analyzeCompactionPolicy(properties, olapTable.getKeysType());
} catch (AnalysisException e) {
throw new DdlException(e.getMessage());
}
diff --git
a/regression-test/suites/datatype_p0/decimalv3/test_decimalv3_overflow.groovy
b/regression-test/suites/datatype_p0/decimalv3/test_decimalv3_overflow.groovy
index b5cfe16a77f..cfea7df12f5 100644
---
a/regression-test/suites/datatype_p0/decimalv3/test_decimalv3_overflow.groovy
+++
b/regression-test/suites/datatype_p0/decimalv3/test_decimalv3_overflow.groovy
@@ -643,7 +643,6 @@ suite("test_decimalv3_overflow") {
DISTRIBUTED BY HASH(`id`) BUCKETS 10
PROPERTIES(
"replication_num"="1",
- "compaction_policy" = "time_series",
"enable_unique_key_merge_on_write" = "true"
); """
sql """ insert into test4 values(1, 62324, 0.00273) """
diff --git
a/regression-test/suites/unique_with_mow_p0/test_mow_time_series_compaction.groovy
b/regression-test/suites/unique_with_mow_p0/test_mow_time_series_compaction.groovy
new file mode 100644
index 00000000000..4d422edc36a
--- /dev/null
+++
b/regression-test/suites/unique_with_mow_p0/test_mow_time_series_compaction.groovy
@@ -0,0 +1,81 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_mow_time_series_compaction") {
+ def tableName = "test_mow_time_series_compaction"
+ sql """ DROP TABLE IF EXISTS ${tableName} """
+ test {
+ sql """ CREATE TABLE ${tableName}
+ (k int, v1 int, v2 int )
+ UNIQUE KEY(k)
+ DISTRIBUTED BY HASH (k)
+ BUCKETS 1 PROPERTIES(
+ "replication_num" = "1",
+ "enable_unique_key_merge_on_write"="true",
+ "compaction_policy" = "time_series");
+ """
+ exception "Time series compaction policy is not supported for unique
key table"
+ }
+
+ tableName = "test_mor_time_series_compaction"
+ sql """ DROP TABLE IF EXISTS ${tableName} """
+ test {
+ sql """ CREATE TABLE ${tableName}
+ (k int, v1 int, v2 int )
+ UNIQUE KEY(k)
+ DISTRIBUTED BY HASH (k)
+ BUCKETS 1 PROPERTIES(
+ "replication_num" = "1",
+ "enable_unique_key_merge_on_write"="false",
+ "compaction_policy" = "time_series");
+ """
+ exception "Time series compaction policy is not supported for unique
key table"
+ }
+
+ tableName = "test_mow_time_series_compaction_2"
+ sql """ DROP TABLE IF EXISTS ${tableName} """
+ sql """ CREATE TABLE ${tableName}
+ (k int, v1 int, v2 int )
+ UNIQUE KEY(k)
+ DISTRIBUTED BY HASH (k)
+ BUCKETS 1 PROPERTIES(
+ "replication_num" = "1",
+ "enable_unique_key_merge_on_write"="true");
+ """
+ sql "insert into ${tableName} values (1, 1, 1),(2,2,2),(3,3,3);"
+ test {
+ sql "alter table ${tableName} set (\"compaction_policy\" =
\"time_series\");"
+ exception "Time series compaction policy is not supported for unique
key table"
+ }
+
+ tableName = "test_mor_time_series_compaction_2"
+ sql """ DROP TABLE IF EXISTS ${tableName} """
+ sql """ CREATE TABLE ${tableName}
+ (k int, v1 int, v2 int )
+ UNIQUE KEY(k)
+ DISTRIBUTED BY HASH (k)
+ BUCKETS 1 PROPERTIES(
+ "replication_num" = "1",
+ "enable_unique_key_merge_on_write"="false");
+ """
+ sql "insert into ${tableName} values (1, 1, 1),(2,2,2),(3,3,3);"
+ test {
+ sql "alter table ${tableName} set (\"compaction_policy\" =
\"time_series\");"
+ exception "Time series compaction policy is not supported for unique
key table"
+ }
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]