This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 53f9dc70d8c [fix](tablesample) Fix computeSampleTabletIds 
NullPointerException (#27165) (#27258)
53f9dc70d8c is described below

commit 53f9dc70d8c2f3ba0df7760d6a5320127d2a29d6
Author: Xinyi Zou <[email protected]>
AuthorDate: Mon Nov 20 17:56:21 2023 +0800

    [fix](tablesample) Fix computeSampleTabletIds NullPointerException (#27165) 
(#27258)
---
 .../src/main/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 b77a3bb285f..ae195d9ed44 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
@@ -947,9 +947,13 @@ public class OlapScanNode extends ScanNode {
         }
         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());
 
@@ -969,7 +973,7 @@ public class OlapScanNode extends ScanNode {
         // 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));


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to