Skip to content

Commit

Permalink
[fix](iceberg) fix iceberg count(*) short circuit read bug (apache#23402
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wuwenchi authored and tudouzhao committed Aug 26, 2023
1 parent 263c42d commit 7eb3614
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 @@ -434,7 +435,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 @@ -797,9 +800,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 @@ -815,7 +816,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 @@ -41,6 +41,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 @@ -93,6 +94,8 @@ public class PlanTranslatorContext {

private final Map<PlanFragmentId, CTEScanNode> cteScanNodeMap = Maps.newHashMap();

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

public PlanTranslatorContext(CascadesContext ctx) {
this.translator = new RuntimeFilterTranslator(ctx.getRuntimeFilterContext());
}
Expand Down Expand Up @@ -235,4 +238,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 7eb3614

Please sign in to comment.