Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2242,6 +2242,11 @@ public void updateTableProperties(Database db, String tableName, Map<String, Str
+ " 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,8 @@ public static Boolean analyzeSkipWriteIndexOnLoad(Map<String, String> properties
+ " 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;
}
Expand All @@ -762,6 +763,9 @@ public static String analyzeCompactionPolicy(Map<String, String> properties) thr
}
}

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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2399,7 +2399,7 @@ private boolean createOlapTable(Database db, CreateTableStmt stmt) throws UserEx
// 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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) """
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}

}