From 5fe8146f58d2dd28ce9ca314a12588d590a38d76 Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Thu, 12 Oct 2023 21:10:51 +0800 Subject: [PATCH] 1 --- .../apache/doris/planner/OlapScanNode.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java index bb10d7620819478..31f814260f2699e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java @@ -1026,19 +1026,28 @@ private void computeTabletInfo() throws UserException { final Partition partition = olapTable.getPartition(partitionId); final MaterializedIndex selectedTable = partition.getIndex(selectedIndexId); final List tablets = Lists.newArrayList(); - final Collection tabletIds = distributionPrune(selectedTable, partition.getDistributionInfo()); + Collection tabletIds = distributionPrune(selectedTable, partition.getDistributionInfo()); LOG.debug("distribution prune tablets: {}", tabletIds); - if (tabletIds != null && sampleTabletIds.size() != 0) { - tabletIds.retainAll(sampleTabletIds); + if (sampleTabletIds.size() != 0) { + if (tabletIds != null) { + tabletIds.retainAll(sampleTabletIds); + } else { + tabletIds = sampleTabletIds; + } LOG.debug("after sample tablets: {}", tabletIds); } List allTabletIds = selectedTable.getTabletIdsInOrder(); if (tabletIds != null) { for (Long id : tabletIds) { - tablets.add(selectedTable.getTablet(id)); + if (selectedTable.getTablet(id) != null) { + tablets.add(selectedTable.getTablet(id)); + scanTabletIds.add(id); + } else { + // The tabletID specified in query does not exist in this partition, skip. + Preconditions.checkState(sampleTabletIds.size() != 0); + } } - scanTabletIds.addAll(tabletIds); } else { tablets.addAll(selectedTable.getTablets()); scanTabletIds.addAll(allTabletIds);