[Chore](sink) add index number check for table sink (#25461)

add index number check for table sink
This commit is contained in:
Pxl
2023-10-16 17:03:26 +08:00
committed by GitHub
parent 9deda929b9
commit d41e839ea0
3 changed files with 20 additions and 0 deletions

View File

@ -639,6 +639,10 @@ public class OlapTable extends Table {
return Status.OK;
}
public int getIndexNumber() {
return indexIdToMeta.size();
}
public Map<Long, MaterializedIndexMeta> getIndexIdToMeta() {
return indexIdToMeta;
}

View File

@ -174,6 +174,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());

View File

@ -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();