You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by kx...@apache.org on 2023/10/16 16:05:03 UTC
[doris] 10/15: [Chore](sink) add index number check for table sink (#25461)
This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
commit fc37baaf53b773235a90799e492da5cbe022d0cf
Author: Pxl <px...@qq.com>
AuthorDate: Mon Oct 16 17:03:26 2023 +0800
[Chore](sink) add index number check for table sink (#25461)
add index number check for table sink
---
.../src/main/java/org/apache/doris/catalog/OlapTable.java | 4 ++++
.../src/main/java/org/apache/doris/planner/OlapTableSink.java | 10 ++++++++++
.../test/java/org/apache/doris/planner/OlapTableSinkTest.java | 6 ++++++
3 files changed, 20 insertions(+)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
index bc0073f7ef9..0f6ffc3cf6b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
@@ -620,6 +620,10 @@ public class OlapTable extends Table {
return Status.OK;
}
+ public int getIndexNumber() {
+ return indexIdToMeta.size();
+ }
+
public Map<Long, MaterializedIndexMeta> getIndexIdToMeta() {
return indexIdToMeta;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapTableSink.java b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapTableSink.java
index ceee31a721d..d073f0b1394 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapTableSink.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapTableSink.java
@@ -166,6 +166,16 @@ public class OlapTableSink extends DataSink {
// must called after tupleDescriptor is computed
public void complete(Analyzer analyzer) throws UserException {
+ for (Long partitionId : partitionIds) {
+ Partition partition = dstTable.getPartition(partitionId);
+ if (dstTable.getIndexNumber() != partition.getMaterializedIndices(IndexExtState.ALL).size()) {
+ throw new UserException(
+ "table's index number not equal with partition's index number. table's index number="
+ + dstTable.getIndexIdToMeta().size() + ", partition's index number="
+ + partition.getMaterializedIndices(IndexExtState.ALL).size());
+ }
+ }
+
TOlapTableSink tSink = tDataSink.getOlapTableSink();
tSink.setTableId(dstTable.getId());
diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/OlapTableSinkTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/OlapTableSinkTest.java
index dc98026a00e..0ebea0e3b35 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/planner/OlapTableSinkTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/planner/OlapTableSinkTest.java
@@ -92,6 +92,8 @@ public class OlapTableSinkTest {
new Expectations() {
{
+ dstTable.getIndexNumber();
+ result = 1;
dstTable.getId();
result = 1;
dstTable.getPartitionInfo();
@@ -128,6 +130,8 @@ public class OlapTableSinkTest {
new Expectations() {
{
+ dstTable.getIndexNumber();
+ result = 1;
dstTable.getId();
result = 1;
dstTable.getPartitionInfo();
@@ -190,6 +194,8 @@ public class OlapTableSinkTest {
new Expectations() {
{
+ dstTable.getIndexNumber();
+ result = 1;
dstTable.getId();
result = 1;
dstTable.getPartitionInfo();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org