From bb775a4daf4b80f49fc6dca002bbcf0a55f5e224 Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Mon, 6 Nov 2023 09:40:56 +0800 Subject: [PATCH] 1 --- .../java/org/apache/doris/planner/OlapScanNode.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 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 7e6d81db793511..11ed56f1f867ab 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 @@ -948,9 +948,13 @@ public void computeSampleTabletIds() { } for (Long partitionId : selectedPartitionIds) { final Partition partition = olapTable.getPartition(partitionId); - final MaterializedIndex selectedTable = partition.getIndex(selectedIndexId); - selectedRows += selectedTable.getRowCount(); - selectedPartitionList.add(partitionId); + final MaterializedIndex selectedIndex = partition.getIndex(selectedIndexId); + // selectedIndex is not expected to be null, because MaterializedIndex ids in one rollup's partitions + // are all same. skip this partition here. + if (selectedIndex != null) { + selectedRows += selectedIndex.getRowCount(); + selectedPartitionList.add(partitionId); + } } selectedPartitionList.sort(Comparator.naturalOrder()); @@ -970,7 +974,7 @@ public void computeSampleTabletIds() { // 3. Sampling partition. If Seek is specified, the partition will be the same for each sampling. long hitRows = 0; // The number of rows hit by the tablet long partitionSeek = tableSample.getSeek() != -1 - ? tableSample.getSeek() : (long) (new SecureRandom().nextDouble() * selectedPartitionIds.size()); + ? tableSample.getSeek() : (long) (new SecureRandom().nextDouble() * selectedPartitionList.size()); for (int i = 0; i < selectedPartitionList.size(); i++) { int seekPid = (int) ((i + partitionSeek) % selectedPartitionList.size()); final Partition partition = olapTable.getPartition(selectedPartitionList.get(seekPid));