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 2022/12/19 05:10:52 UTC
[doris] 18/21: [fix](schema) Fix create table error if Colocate tables not equal to bucket num (#15071)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 62342915065f41170b18be2b72bd4981e5fd4a71
Author: yuxuan-luo <11...@users.noreply.github.com>
AuthorDate: Mon Dec 19 09:24:14 2022 +0800
[fix](schema) Fix create table error if Colocate tables not equal to bucket num (#15071)
Co-authored-by: hugoluo <hu...@tencent.com>
---
.../java/org/apache/doris/catalog/ColocateGroupSchema.java | 12 ++++++++++++
.../src/main/java/org/apache/doris/common/ErrorCode.java | 2 ++
.../java/org/apache/doris/datasource/InternalCatalog.java | 1 +
3 files changed, 15 insertions(+)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateGroupSchema.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateGroupSchema.java
index 7d76a25cd0..ff1c957cd4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateGroupSchema.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColocateGroupSchema.java
@@ -30,6 +30,7 @@ import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
/*
@@ -113,6 +114,17 @@ public class ColocateGroupSchema implements Writable {
}
}
+ public void checkDynamicPartition(Map<String, String> properties,
+ DistributionInfo distributionInfo) throws DdlException {
+ if (properties.get(DynamicPartitionProperty.BUCKETS) != null) {
+ HashDistributionInfo info = (HashDistributionInfo) distributionInfo;
+ if (info.getBucketNum() != Integer.parseInt(properties.get(DynamicPartitionProperty.BUCKETS))) {
+ ErrorReport.reportDdlException(
+ ErrorCode.ERR_DYNAMIC_PARTITION_MUST_HAS_SAME_BUCKET_NUM_WITH_COLOCATE_TABLE, bucketsNum);
+ }
+ }
+ }
+
public static ColocateGroupSchema read(DataInput in) throws IOException {
ColocateGroupSchema schema = new ColocateGroupSchema();
schema.readFields(in);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java b/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java
index 4f21d77a0c..a6a78d054b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/ErrorCode.java
@@ -1635,6 +1635,8 @@ public enum ErrorCode {
ERR_COLOCATE_NOT_COLOCATE_TABLE(5064, new byte[]{'4', '2', '0', '0', '0'},
"Table %s is not a colocated table"),
ERR_INVALID_OPERATION(5065, new byte[]{'4', '2', '0', '0', '0'}, "Operation %s is invalid"),
+ ERR_DYNAMIC_PARTITION_MUST_HAS_SAME_BUCKET_NUM_WITH_COLOCATE_TABLE(5063, new byte[]{'4', '2', '0', '0', '0'},
+ "Dynamic partition buckets must equal the distribution buckets if creating a colocate table: %s"),
ERROR_DYNAMIC_PARTITION_TIME_UNIT(5065, new byte[]{'4', '2', '0', '0', '0'},
"Unsupported time unit %s. Expect HOUR/DAY/WEEK/MONTH."),
ERROR_DYNAMIC_PARTITION_START_ZERO(5066, new byte[]{'4', '2', '0', '0', '0'},
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 22bf478c7b..6466a29e12 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
@@ -1970,6 +1970,7 @@ public class InternalCatalog implements CatalogIf<Database> {
if (groupSchema != null) {
// group already exist, check if this table can be added to this group
groupSchema.checkColocateSchema(olapTable);
+ groupSchema.checkDynamicPartition(properties, olapTable.getDefaultDistributionInfo());
}
// add table to this group, if group does not exist, create a new one
Env.getCurrentColocateIndex()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org