Skip to content

Commit

Permalink
[Chore](sink) add index number check for table sink (#25461)
Browse files Browse the repository at this point in the history
add index number check for table sink
  • Loading branch information
BiteTheDDDDt authored and pull[bot] committed Dec 1, 2023
1 parent 002c252 commit 569b3b9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,10 @@ public Status resetIdsForRestore(Env env, Database db, ReplicaAllocation restore
return Status.OK;
}

public int getIndexNumber() {
return indexIdToMeta.size();
}

public Map<Long, MaterializedIndexMeta> getIndexIdToMeta() {
return indexIdToMeta;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ public void updateLoadId(TUniqueId newLoadId) {

// 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public void testSinglePartition() throws UserException {

new Expectations() {
{
dstTable.getIndexNumber();
result = 1;
dstTable.getId();
result = 1;
dstTable.getPartitionInfo();
Expand Down Expand Up @@ -128,6 +130,8 @@ public void testRangePartition(

new Expectations() {
{
dstTable.getIndexNumber();
result = 1;
dstTable.getId();
result = 1;
dstTable.getPartitionInfo();
Expand Down Expand Up @@ -190,6 +194,8 @@ public void testListPartition(

new Expectations() {
{
dstTable.getIndexNumber();
result = 1;
dstTable.getId();
result = 1;
dstTable.getPartitionInfo();
Expand Down

0 comments on commit 569b3b9

Please sign in to comment.