Skip to content

Commit 66557d3

Browse files
committed
update
1 parent 9c24654 commit 66557d3

3 files changed

Lines changed: 18 additions & 58 deletions

File tree

‎fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java‎

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,18 +1009,6 @@ private PlanFragment computePhysicalOlapScan(PhysicalOlapScan olapScan, PlanTran
10091009
return planFragment;
10101010
}
10111011

1012-
private long getSelectedIndexId(OlapScanNode scanNode) {
1013-
return scanNode.getSelectedIndexId() == -1
1014-
? scanNode.getOlapTable().getBaseIndexId()
1015-
: scanNode.getSelectedIndexId();
1016-
}
1017-
1018-
private boolean shouldAlignStorageKeySlots(OlapTable olapTable, long selectedIndexId) {
1019-
KeysType keysType = olapTable.getIndexMetaByIndexId(selectedIndexId).getKeysType();
1020-
return keysType == KeysType.AGG_KEYS
1021-
|| (keysType == KeysType.UNIQUE_KEYS && !olapTable.getEnableUniqueKeyMergeOnWrite());
1022-
}
1023-
10241012
private void translateRuntimeFilter(PhysicalRelation physicalRelation, ScanNode scanNode,
10251013
PlanTranslatorContext context) {
10261014
if (context.getRuntimeTranslator().isPresent()) {
@@ -2932,7 +2920,6 @@ public PlanFragment visitPhysicalLazyMaterializeOlapScan(PhysicalLazyMaterialize
29322920
Set<SlotId> scanIds = lazyScan.getOutput().stream().map(NamedExpression::getExprId)
29332921
.map(context::findSlotRef).filter(Objects::nonNull).map(SlotRef::getSlotId)
29342922
.collect(Collectors.toSet());
2935-
preserveExtraStorageKeySlots(olapScanNode, scanIds);
29362923

29372924
olapScanNode.getTupleDesc().getSlots().removeIf(slot -> !scanIds.contains(slot.getId()));
29382925
context.createSlotDesc(olapScanNode.getTupleDesc(), lazyScan.getRowId());
@@ -2944,18 +2931,6 @@ public PlanFragment visitPhysicalLazyMaterializeOlapScan(PhysicalLazyMaterialize
29442931

29452932
translateRuntimeFilter(lazyScan, olapScanNode, context);
29462933

2947-
if (!olapScanNode.getExtraKeyColumnSlotIds().isEmpty()) {
2948-
// Extra storage keys stay in the scan tuple for storage semantics, but the lazy-scan
2949-
// output must still match lazyScan.getOutput(). Keep a projection to hide those keys
2950-
// from parent operators.
2951-
List<Expr> projectionExprs = lazyScan.getOutput().stream()
2952-
.map(slot -> context.findSlotRef(slot.getExprId()))
2953-
.collect(Collectors.toList());
2954-
TupleDescriptor projectionTuple = generateTupleDesc(lazyScan.getOutput(), lazyScan.getTable(), context);
2955-
olapScanNode.setProjectList(projectionExprs);
2956-
olapScanNode.setOutputTupleDesc(projectionTuple);
2957-
}
2958-
29592934
return planFragment;
29602935
}
29612936

@@ -3071,7 +3046,12 @@ private boolean shouldPreserveStorageKeySlots(OlapScanNode scanNode) {
30713046
if (scanNode.isIncrementalScan()) {
30723047
return false;
30733048
}
3074-
return shouldAlignStorageKeySlots(scanNode.getOlapTable(), getSelectedIndexId(scanNode));
3049+
long selectedIndexId = scanNode.getSelectedIndexId() == -1
3050+
? scanNode.getOlapTable().getBaseIndexId()
3051+
: scanNode.getSelectedIndexId();
3052+
KeysType keysType = scanNode.getOlapTable().getIndexMetaByIndexId(selectedIndexId).getKeysType();
3053+
return keysType == KeysType.AGG_KEYS
3054+
|| (keysType == KeysType.UNIQUE_KEYS && !scanNode.getOlapTable().getEnableUniqueKeyMergeOnWrite());
30753055
}
30763056

30773057
/**

‎fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,6 @@ public void setTableSample(TableSample tSample) {
270270
this.tableSample = tSample;
271271
}
272272

273-
public void setExtraKeyColumnSlotIds(Set<Integer> extraKeyColumnSlotIds) {
274-
this.extraKeyColumnSlotIds = extraKeyColumnSlotIds;
275-
}
276-
277273
public Set<Integer> getExtraKeyColumnSlotIds() {
278274
return extraKeyColumnSlotIds;
279275
}

‎fe/fe-core/src/test/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslatorTest.java‎

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,9 @@
2222
import org.apache.doris.analysis.SlotRef;
2323
import org.apache.doris.analysis.TupleDescriptor;
2424
import org.apache.doris.analysis.TupleId;
25-
import org.apache.doris.catalog.AggregateType;
2625
import org.apache.doris.catalog.Column;
27-
import org.apache.doris.catalog.HashDistributionInfo;
2826
import org.apache.doris.catalog.KeysType;
2927
import org.apache.doris.catalog.OlapTable;
30-
import org.apache.doris.catalog.PartitionInfo;
31-
import org.apache.doris.catalog.Type;
3228
import org.apache.doris.common.UserException;
3329
import org.apache.doris.nereids.NereidsPlanner;
3430
import org.apache.doris.nereids.properties.DataTrait;
@@ -49,6 +45,7 @@
4945
import org.apache.doris.nereids.trees.plans.physical.PhysicalProject;
5046
import org.apache.doris.nereids.types.IntegerType;
5147
import org.apache.doris.nereids.util.PlanChecker;
48+
import org.apache.doris.nereids.util.PlanConstructor;
5249
import org.apache.doris.planner.AggregationNode;
5350
import org.apache.doris.planner.OlapScanNode;
5451
import org.apache.doris.planner.PlanFragment;
@@ -61,7 +58,6 @@
6158
import org.apache.doris.thrift.TExplainLevel;
6259
import org.apache.doris.thrift.TPlanNode;
6360
import org.apache.doris.thrift.TScanRangeLocations;
64-
import org.apache.doris.thrift.TStorageType;
6561
import org.apache.doris.utframe.TestWithFeService;
6662

6763
import com.google.common.collect.ImmutableList;
@@ -104,26 +100,14 @@ protected void runBeforeAll() throws Exception {
104100
@Test
105101
public void testOlapPrune() throws Exception {
106102
LogicalProperties placeHolder = Mockito.mock(LogicalProperties.class);
107-
List<Column> columns = ImmutableList.of(
108-
new Column("id", Type.INT, true, AggregateType.NONE, "0", ""),
109-
new Column("name", Type.STRING, true, AggregateType.NONE, "", ""),
110-
new Column("value", Type.INT, false, AggregateType.SUM, "0", ""));
111-
OlapTable t1 = new OlapTable(0, "t1", columns, KeysType.AGG_KEYS, new PartitionInfo(),
112-
new HashDistributionInfo(3, ImmutableList.of(columns.get(0))));
113-
t1.setIndexMeta(-1, "t1", t1.getFullSchema(), 0, 0, (short) 0, TStorageType.COLUMN,
114-
KeysType.AGG_KEYS);
103+
OlapTable t1 = PlanConstructor.newOlapTable(0, "t1", 0, KeysType.AGG_KEYS);
115104
List<String> qualifier = new ArrayList<>();
116105
qualifier.add("test");
117-
List<Slot> t1Output = new ArrayList<>();
118106
SlotReference col1 = SlotReference.fromColumn(StatementScopeIdGenerator.newExprId(),
119107
t1, t1.getBaseSchema().get(0), qualifier);
120108
SlotReference col2 = SlotReference.fromColumn(StatementScopeIdGenerator.newExprId(),
121109
t1, t1.getBaseSchema().get(1), qualifier);
122-
SlotReference col3 = SlotReference.fromColumn(StatementScopeIdGenerator.newExprId(),
123-
t1, t1.getBaseSchema().get(2), qualifier);
124-
t1Output.add(col1);
125-
t1Output.add(col2);
126-
t1Output.add(col3);
110+
List<Slot> t1Output = ImmutableList.of(col1, col2);
127111
LogicalProperties t1Properties = new LogicalProperties(new Supplier<List<Slot>>() {
128112
@Override
129113
public List<Slot> get() {
@@ -135,22 +119,22 @@ public DataTrait get() {
135119
return DataTrait.EMPTY_TRAIT;
136120
}
137121
});
138-
PhysicalOlapScan scan = new PhysicalOlapScan(StatementScopeIdGenerator.newRelationId(), t1, qualifier, t1.getBaseIndexId(),
139-
Collections.emptyList(), Collections.emptyList(), null, PreAggStatus.on(),
140-
ImmutableList.of(), Optional.empty(), t1Properties, Optional.empty(),
141-
ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), Optional.empty(),
142-
Optional.empty(), ImmutableList.of(), Optional.empty());
122+
PhysicalOlapScan scan = new PhysicalOlapScan(StatementScopeIdGenerator.newRelationId(), t1, qualifier,
123+
t1.getBaseIndexId(), Collections.emptyList(), Collections.emptyList(), null, PreAggStatus.on(),
124+
ImmutableList.of(), Optional.empty(), t1Properties, Optional.empty(), ImmutableList.of(),
125+
ImmutableList.of(), ImmutableList.of(), Optional.empty(), Optional.empty(), ImmutableList.of(),
126+
Optional.empty());
143127
Literal t1FilterRight = new IntegerLiteral(1);
144128
Expression t1FilterExpr = new GreaterThan(col1, t1FilterRight);
145129
PhysicalFilter<PhysicalOlapScan> filter =
146130
new PhysicalFilter<>(ImmutableSet.of(t1FilterExpr), placeHolder, scan);
147-
List<NamedExpression> filterProjectList = new ArrayList<>();
148-
filterProjectList.add(col2);
149-
PhysicalProject<PhysicalFilter<PhysicalOlapScan>> filterProject = new PhysicalProject<>(filterProjectList,
131+
List<NamedExpression> projList = new ArrayList<>();
132+
projList.add(col2);
133+
PhysicalProject<PhysicalFilter<PhysicalOlapScan>> project = new PhysicalProject<>(projList,
150134
placeHolder, filter);
151135
PlanTranslatorContext planTranslatorContext = new PlanTranslatorContext();
152136
PhysicalPlanTranslator translator = new PhysicalPlanTranslator(planTranslatorContext, null);
153-
PlanFragment fragment = translator.visitPhysicalProject(filterProject, planTranslatorContext);
137+
PlanFragment fragment = translator.visitPhysicalProject(project, planTranslatorContext);
154138
PlanNode planNode = fragment.getPlanRoot();
155139
List<OlapScanNode> scanNodeList = new ArrayList<>();
156140
planNode.collect(OlapScanNode.class, scanNodeList);

0 commit comments

Comments
 (0)