[Chore](sink) add index number check for table sink (#25461)
add index number check for table sink
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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();
|
||||
|
||||
Reference in New Issue
Block a user