Skip to content

Commit

Permalink
[fix](iceberg) fix iceberg count(*) short circuit read bug (#23402)
Browse files Browse the repository at this point in the history
  • Loading branch information
wuwenchi authored and xiaokang committed Aug 25, 2023
1 parent 1e4d744 commit 0812951
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
import org.apache.doris.nereids.trees.plans.physical.PhysicalCTEAnchor;
import org.apache.doris.nereids.trees.plans.physical.PhysicalCTEConsumer;
import org.apache.doris.nereids.trees.plans.physical.PhysicalCTEProducer;
import org.apache.doris.nereids.trees.plans.physical.PhysicalCatalogRelation;
import org.apache.doris.nereids.trees.plans.physical.PhysicalDeferMaterializeOlapScan;
import org.apache.doris.nereids.trees.plans.physical.PhysicalDeferMaterializeResultSink;
import org.apache.doris.nereids.trees.plans.physical.PhysicalDeferMaterializeTopN;
Expand Down Expand Up @@ -425,7 +426,9 @@ public PlanFragment visitPhysicalFileScan(PhysicalFileScan fileScan, PlanTransla
} else {
throw new RuntimeException("do not support table type " + table.getType());
}

scanNode.addConjuncts(translateToLegacyConjuncts(fileScan.getConjuncts()));
scanNode.setPushDownAggNoGrouping(context.getTablePushAggOp(table.getId()));

TableName tableName = new TableName(null, "", "");
TableRef ref = new TableRef(tableName, null, null);
Expand Down Expand Up @@ -785,9 +788,7 @@ public PlanFragment visitPhysicalStorageLayerAggregate(
|| storageLayerAggregate.getRelation() instanceof PhysicalFileScan),
"PhysicalStorageLayerAggregate only support PhysicalOlapScan and PhysicalFileScan: "
+ storageLayerAggregate.getRelation().getClass().getName());
PlanFragment planFragment = storageLayerAggregate.getRelation().accept(this, context);

ScanNode scanNode = (ScanNode) planFragment.getPlanRoot();
TPushAggOp pushAggOp;
switch (storageLayerAggregate.getAggOp()) {
case COUNT:
Expand All @@ -806,7 +807,12 @@ public PlanFragment visitPhysicalStorageLayerAggregate(
throw new AnalysisException("Unsupported storage layer aggregate: "
+ storageLayerAggregate.getAggOp());
}
scanNode.setPushDownAggNoGrouping(pushAggOp);

context.setTablePushAggOp(
((PhysicalCatalogRelation) storageLayerAggregate.getRelation()).getTable().getId(), pushAggOp);

PlanFragment planFragment = storageLayerAggregate.getRelation().accept(this, context);

updateLegacyPlanIdToPhysicalPlan(planFragment.getPlanRoot(), storageLayerAggregate);
return planFragment;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.doris.planner.PlanNode;
import org.apache.doris.planner.PlanNodeId;
import org.apache.doris.planner.ScanNode;
import org.apache.doris.thrift.TPushAggOp;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
Expand Down Expand Up @@ -87,6 +88,8 @@ public class PlanTranslatorContext {

private final Map<CTEId, PhysicalCTEProducer> cteProducerMap = Maps.newHashMap();

private final Map<Long, TPushAggOp> tablePushAggOp = Maps.newHashMap();

public PlanTranslatorContext(CascadesContext ctx) {
this.translator = new RuntimeFilterTranslator(ctx.getRuntimeFilterContext());
}
Expand Down Expand Up @@ -221,4 +224,12 @@ public TupleDescriptor getTupleDesc(TupleId tupleId) {
public DescriptorTable getDescTable() {
return descTable;
}

public void setTablePushAggOp(Long tableId, TPushAggOp aggOp) {
tablePushAggOp.put(tableId, aggOp);
}

public TPushAggOp getTablePushAggOp(Long tableId) {
return tablePushAggOp.getOrDefault(tableId, TPushAggOp.NONE);
}
}

0 comments on commit 0812951

Please sign in to comment.