xiaokang commented on code in PR #25378: URL: https://github.com/apache/doris/pull/25378#discussion_r1369419370
########## fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java: ########## @@ -1026,19 +1028,28 @@ private void computeTabletInfo() throws UserException { final Partition partition = olapTable.getPartition(partitionId); final MaterializedIndex selectedTable = partition.getIndex(selectedIndexId); final List<Tablet> tablets = Lists.newArrayList(); - final Collection<Long> tabletIds = distributionPrune(selectedTable, partition.getDistributionInfo()); + Collection<Long> 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; Review Comment: Is this logic related to random bucket? ########## fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java: ########## @@ -831,6 +846,16 @@ public void testSelectTablet() throws Exception { Assert.assertTrue(sampleTabletIds.contains(10033L)); } + @Test + public void testRandomBucketSelectTablet() throws Exception { + String sql1 = "SELECT * FROM db1.table3 TABLET(10031,10032,10033)"; + OriginalPlanner planner = (OriginalPlanner) dorisAssert.query(sql1).internalExecuteOneAndGetPlan(); + Set<Long> sampleTabletIds = ((OlapScanNode) planner.getScanNodes().get(0)).getSampleTabletIds(); + Assert.assertTrue(sampleTabletIds.contains(10031L)); + Assert.assertTrue(sampleTabletIds.contains(10032L)); + Assert.assertTrue(sampleTabletIds.contains(10033L)); + } + @Test public void testSelectSampleTable() throws Exception { Review Comment: add case for random bucket. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org