Skip to content

Commit

Permalink
support query when only restoring a few partitions of this table
Browse files Browse the repository at this point in the history
  • Loading branch information
shenshoucheng authored and Johnnyssc committed Sep 13, 2024
1 parent 4466541 commit fc41ec8
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -830,17 +830,14 @@ public TableRef resolveTableRef(TableRef tableRef) throws AnalysisException {
.getDbOrAnalysisException(tableName.getDb());
TableIf table = database.getTableOrAnalysisException(tableName.getTbl());

if (table.isManagedTable() && (((OlapTable) table).getState() == OlapTableState.RESTORE
|| ((OlapTable) table).getState() == OlapTableState.RESTORE_WITH_LOAD)) {
Boolean isAnyPartitionRestoring = ((OlapTable) table).getPartitions().stream()
.anyMatch(partition -> partition.getState() == PartitionState.RESTORE);
if (isAnyPartitionRestoring) {
// if doing restore with partitions, the status check push down to OlapScanNode::computePartitionInfo to
// support query that partitions is not restoring.
} else {
// if doing restore with table, throw exception here
ErrorReport.reportAnalysisException(ErrorCode.ERR_BAD_TABLE_STATE, "RESTORING");
}
Boolean isAllPartitionRestoring = ((OlapTable) table).getPartitions().stream()
.allMatch(partition -> partition.getState() == PartitionState.RESTORE);

// if doing restore with table, all partition state will set also, throw exception here
// if doing restore with a few of partitions, the status check push down to OlapScanNode::computePartitionInfo to
// support query that partitions is not restoring.
if (table.isManagedTable() && isAllPartitionRestoring) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_BAD_TABLE_STATE, "RESTORING");
}

// Now hms table only support a bit of table kinds in the whole hive system.
Expand Down

0 comments on commit fc41ec8

Please sign in to comment.