Skip to content

Commit

Permalink
[BugFix] Pruning of bucketed columns first follows TABLET HINT (#13142)
Browse files Browse the repository at this point in the history
  • Loading branch information
HangyuanLiu authored and wanpengfei-git committed Nov 14, 2022
1 parent 7b609b9 commit 4e89b11
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Expand Up @@ -45,17 +45,16 @@ public List<OptExpression> transform(OptExpression input, OptimizerContext conte
OlapTable olapTable = (OlapTable) olapScanOperator.getTable();

List<Long> result = Lists.newArrayList();
for (Long partitionId : olapScanOperator.getSelectedPartitionId()) {
Partition partition = olapTable.getPartition(partitionId);
MaterializedIndex table = partition.getIndex(olapScanOperator.getSelectedIndexId());
Collection<Long> tabletIds = distributionPrune(table, partition.getDistributionInfo(), olapScanOperator);
result.addAll(tabletIds);
}

// prune hint tablet
Preconditions.checkState(olapScanOperator.getHintsTabletIds() != null);
if (!olapScanOperator.getHintsTabletIds().isEmpty()) {
result.retainAll(olapScanOperator.getHintsTabletIds());
result.addAll(olapScanOperator.getHintsTabletIds());
} else {
for (Long partitionId : olapScanOperator.getSelectedPartitionId()) {
Partition partition = olapTable.getPartition(partitionId);
MaterializedIndex table = partition.getIndex(olapScanOperator.getSelectedIndexId());
Collection<Long> tabletIds = distributionPrune(table, partition.getDistributionInfo(), olapScanOperator);
result.addAll(tabletIds);
}
}

if (result.equals(olapScanOperator.getSelectedTabletId())) {
Expand Down
Expand Up @@ -169,5 +169,13 @@ public void transform(@Mocked OlapTable olapTable, @Mocked Partition partition,
.get(0);

assertEquals(20, ((LogicalOlapScanOperator) optExpression.getOp()).getSelectedTabletId().size());


LogicalOlapScanOperator olapScanOperator = (LogicalOlapScanOperator) optExpression.getOp();
LogicalOlapScanOperator newScanOperator = new LogicalOlapScanOperator.Builder()
.withOperator(olapScanOperator)
.setSelectedTabletId(Lists.newArrayList(1L, 2L, 3L))
.build();
assertEquals(3, newScanOperator.getSelectedTabletId().size());
}
}

0 comments on commit 4e89b11

Please sign in to comment.