You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/04/19 13:34:52 UTC
[doris] 26/36: [fix](merge-on-write) enable_unique_key_merge_on_write property should only be used for unique table (#18734)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-2.0-alpha
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 23a3229d9adcc88a40d1b77126074ddc0b171058
Author: Xin Liao <li...@126.com>
AuthorDate: Tue Apr 18 18:40:01 2023 +0800
[fix](merge-on-write) enable_unique_key_merge_on_write property should only be used for unique table (#18734)
---
.../apache/doris/datasource/InternalCatalog.java | 12 +--
.../suites/ddl_p0/test_create_table.groovy | 3 +-
.../unique_with_mow_p0/test_create_table.groovy | 97 ++++++++++++++++++++++
3 files changed, 105 insertions(+), 7 deletions(-)
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 292723e091..290eddf9c1 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
@@ -1956,11 +1956,13 @@ public class InternalCatalog implements CatalogIf<Database> {
keysDesc.keysColumnSize(), storageFormat);
olapTable.setDataSortInfo(dataSortInfo);
- boolean enableUniqueKeyMergeOnWrite;
- try {
- enableUniqueKeyMergeOnWrite = PropertyAnalyzer.analyzeUniqueKeyMergeOnWrite(properties);
- } catch (AnalysisException e) {
- throw new DdlException(e.getMessage());
+ boolean enableUniqueKeyMergeOnWrite = false;
+ if (keysType == KeysType.UNIQUE_KEYS) {
+ try {
+ enableUniqueKeyMergeOnWrite = PropertyAnalyzer.analyzeUniqueKeyMergeOnWrite(properties);
+ } catch (AnalysisException e) {
+ throw new DdlException(e.getMessage());
+ }
}
olapTable.setEnableUniqueKeyMergeOnWrite(enableUniqueKeyMergeOnWrite);
diff --git a/regression-test/suites/ddl_p0/test_create_table.groovy b/regression-test/suites/ddl_p0/test_create_table.groovy
index dd7340cbbb..a022f51e52 100644
--- a/regression-test/suites/ddl_p0/test_create_table.groovy
+++ b/regression-test/suites/ddl_p0/test_create_table.groovy
@@ -42,8 +42,7 @@ suite("sql_create_time_range_table") {
properties(
"replication_num"="1",
"light_schema_change"="true",
- "compression"="zstd",
- "enable_unique_key_merge_on_write" = "true"
+ "compression"="zstd"
);
"""
diff --git a/regression-test/suites/unique_with_mow_p0/test_create_table.groovy b/regression-test/suites/unique_with_mow_p0/test_create_table.groovy
new file mode 100644
index 0000000000..9a3ad4b2a5
--- /dev/null
+++ b/regression-test/suites/unique_with_mow_p0/test_create_table.groovy
@@ -0,0 +1,97 @@
+// 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_create_table") {
+ def tableName = "unique_mow_create_table"
+ sql """ DROP TABLE IF EXISTS ${tableName} """
+
+ // duplicate table with enable_unique_key_merge_on_write property
+ test {
+ sql """
+ CREATE TABLE `$tableName` (
+ `c_custkey` int(11) NOT NULL COMMENT "",
+ `c_name` varchar(26) NOT NULL COMMENT "",
+ `c_address` varchar(41) NOT NULL COMMENT "",
+ `c_city` varchar(11) NOT NULL COMMENT ""
+ )
+ DUPLICATE KEY (`c_custkey`)
+ DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1",
+ "enable_unique_key_merge_on_write" = "true"
+ );
+ """
+ exception "Unknown properties"
+ }
+
+ // duplicate table with enable_unique_key_merge_on_write property
+ test {
+ sql """
+ CREATE TABLE `$tableName` (
+ `c_custkey` int(11) NOT NULL COMMENT "",
+ `c_name` varchar(26) NOT NULL COMMENT "",
+ `c_address` varchar(41) NOT NULL COMMENT "",
+ `c_city` varchar(11) NOT NULL COMMENT ""
+ )
+ DUPLICATE KEY (`c_custkey`)
+ DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1",
+ "enable_unique_key_merge_on_write" = "false"
+ );
+ """
+ exception "Unknown properties"
+ }
+
+ // agg table with enable_unique_key_merge_on_write property
+ test {
+ sql """
+ CREATE TABLE `$tableName` (
+ `c_custkey` int(11) NOT NULL COMMENT "",
+ `c_name` varchar(26) max NOT NULL COMMENT "",
+ `c_address` varchar(41) max NOT NULL COMMENT "",
+ `c_city` varchar(11) max NOT NULL COMMENT ""
+ )
+ AGGREGATE KEY (`c_custkey`)
+ DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1",
+ "enable_unique_key_merge_on_write" = "true"
+ );
+ """
+ exception "Unknown properties"
+ }
+
+ // agg table with enable_unique_key_merge_on_write property
+ test {
+ sql """
+ CREATE TABLE `$tableName` (
+ `c_custkey` int(11) NOT NULL COMMENT "",
+ `c_name` varchar(26) max NOT NULL COMMENT "",
+ `c_address` varchar(41) max NOT NULL COMMENT "",
+ `c_city` varchar(11) max NOT NULL COMMENT ""
+ )
+ AGGREGATE KEY (`c_custkey`)
+ DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 1
+ PROPERTIES (
+ "replication_num" = "1",
+ "enable_unique_key_merge_on_write" = "false"
+ );
+ """
+ exception "Unknown properties"
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org