Skip to content

Commit

Permalink
[BugFix] Pruning of bucketed columns first follows TABLET HINT (StarR…
Browse files Browse the repository at this point in the history
  • Loading branch information
HangyuanLiu authored and mergify[bot] committed Nov 11, 2022
1 parent 183cfbe commit 17a3da0
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 @@ -166,5 +166,13 @@ public void transform(@Mocked OlapTable olapTable, @Mocked Partition partition,
OptExpression optExpression = rule.transform(new OptExpression(operator), new OptimizerContext(new Memo(), new ColumnRefFactory())).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 17a3da0

Please sign in to comment.