diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java index 00718d28c12bc9..e1b3f692e506a6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DescriptorTable.java @@ -51,7 +51,7 @@ public TupleDescriptor createTupleDescriptor() { } public SlotDescriptor addSlotDescriptor(TupleDescriptor d) { - SlotDescriptor result = new SlotDescriptor(slotIdGenerator.getNextId(), d); + SlotDescriptor result = new SlotDescriptor(slotIdGenerator.getNextId(), d.getId()); d.addSlot(result); slotDescs.put(result.getId(), result); return result; diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprToThriftVisitor.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprToThriftVisitor.java index 7161417cc3e8e8..69a944e8efc98f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprToThriftVisitor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprToThriftVisitor.java @@ -290,7 +290,7 @@ public Void visitPlaceHolderExpr(PlaceHolderExpr expr, TExprNode msg) { @Override public Void visitSlotRef(SlotRef expr, TExprNode msg) { msg.node_type = TExprNodeType.SLOT_REF; - msg.slot_ref = new TSlotRef(expr.getDesc().getId().asInt(), expr.getDesc().getParent().getId().asInt()); + msg.slot_ref = new TSlotRef(expr.getDesc().getId().asInt(), expr.getDesc().getParentId().asInt()); msg.slot_ref.setColUniqueId(expr.getDesc().getUniqueId()); msg.slot_ref.setIsVirtualSlot(expr.getDesc().getVirtualColumn() != null); msg.setLabel(expr.getLabel()); diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotDescriptor.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotDescriptor.java index f965980d5347e9..10727a5b43cfc5 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotDescriptor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotDescriptor.java @@ -36,7 +36,7 @@ public class SlotDescriptor { private static final Logger LOG = LogManager.getLogger(SlotDescriptor.class); private final SlotId id; - private final TupleDescriptor parent; + private final TupleId parentId; private Type type; private Column column; // underlying column, if there is one @@ -66,22 +66,12 @@ public class SlotDescriptor { private List displayAllAccessPaths; private List displayPredicateAccessPaths; - public SlotDescriptor(SlotId id, TupleDescriptor parent) { - + public SlotDescriptor(SlotId id, TupleId parentId) { this.id = id; - this.parent = parent; + this.parentId = parentId; this.isNullable = true; } - public SlotDescriptor(SlotId id, TupleDescriptor parent, SlotDescriptor src) { - this.id = id; - this.parent = parent; - this.column = src.column; - this.isNullable = src.isNullable; - this.type = src.type; - this.sourceExprs.add(new SlotRef(src)); - } - public SlotId getId() { return id; } @@ -126,8 +116,8 @@ public void setDisplayPredicateAccessPaths(List displayPredic this.displayPredicateAccessPaths = displayPredicateAccessPaths; } - public TupleDescriptor getParent() { - return parent; + public TupleId getParentId() { + return parentId; } public Type getType() { @@ -203,7 +193,7 @@ public TSlotDescriptor toThrift() { // Non-nullable slots will have 0 for the byte offset and -1 for the bit mask String colName = materializedColumnName != null ? materializedColumnName : ((column != null) ? column.getNonShadowName() : ""); - TSlotDescriptor tSlotDescriptor = new TSlotDescriptor(id.asInt(), parent.getId().asInt(), type.toThrift(), -1, + TSlotDescriptor tSlotDescriptor = new TSlotDescriptor(id.asInt(), parentId.asInt(), type.toThrift(), -1, 0, 0, getIsNullable() ? 0 : -1, colName, -1, true); tSlotDescriptor.setIsAutoIncrement(isAutoInc); @@ -265,7 +255,7 @@ public void setCaptionAndNormalize(String caption) { public String debugString() { String typeStr = (type == null ? "null" : type.toString()); - String parentTupleId = (parent == null) ? "null" : parent.getId().toString(); + String parentTupleId = (parentId == null) ? "null" : parentId.toString(); return MoreObjects.toStringHelper(this).add("id", id.asInt()).add("parent", parentTupleId).add("col", caption) .add("type", typeStr).add("nullable", getIsNullable()) .add("isAutoIncrement", isAutoInc).add("subColPath", subColPath) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java index 39143fa5c6caaf..79cf0815d2cdd3 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotRef.java @@ -80,7 +80,7 @@ public SlotRef(Type type, boolean nullable) { // tuple id and slot id is meaningless here, nereids just use type and nullable // to build the TAggregateExpr.param_types TupleDescriptor tupleDescriptor = new TupleDescriptor(new TupleId(-1)); - desc = new SlotDescriptor(new SlotId(-1), tupleDescriptor); + desc = new SlotDescriptor(new SlotId(-1), tupleDescriptor.getId()); tupleDescriptor.addSlot(desc); desc.setIsNullable(nullable); this.nullable = nullable; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/RuntimeFilterTranslator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/RuntimeFilterTranslator.java index c86cec7d2f258f..130996a502dcc0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/RuntimeFilterTranslator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/RuntimeFilterTranslator.java @@ -136,7 +136,7 @@ public void createLegacyRuntimeFilter(RuntimeFilter filter, JoinNodeBase node, P targetExpr = new CastExpr(src.getType(), targetExpr, Cast.castNullable(src.isNullable(), DataType.fromCatalogType(src.getType()), DataType.fromCatalogType(targetExpr.getType()))); } - TupleId targetTupleId = targetSlotRef.getDesc().getParent().getId(); + TupleId targetTupleId = targetSlotRef.getDesc().getParentId(); SlotId targetSlotId = targetSlotRef.getSlotId(); scanNodeList.add(scanNode); targetExprList.add(targetExpr); diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/ExprToSqlTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/ExprToSqlTest.java index 0611907ff18e51..c540be303d2b26 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/analysis/ExprToSqlTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/ExprToSqlTest.java @@ -294,7 +294,7 @@ public void testSlotRefLabelNereidsNotQuery() { // isNereids=true, isQuery=false, sessionVariable set, desc set // → Nereids plan-printing path: label + "[#]" TupleDescriptor tupleDesc = new TupleDescriptor(new TupleId(0)); - SlotDescriptor slotDesc = new SlotDescriptor(new SlotId(3), tupleDesc); + SlotDescriptor slotDesc = new SlotDescriptor(new SlotId(3), tupleDesc.getId()); slotDesc.setLabel("`col`"); SlotRef expr = new SlotRef(null, "col"); expr.setDesc(slotDesc); @@ -307,7 +307,7 @@ public void testSlotRefLabelNereidsNotQuery() { public void testSlotRefLabelNereidsIsQuery() { // isNereids=true, isQuery=true → query execution path, slot-id suffix suppressed TupleDescriptor tupleDesc = new TupleDescriptor(new TupleId(0)); - SlotDescriptor slotDesc = new SlotDescriptor(new SlotId(5), tupleDesc); + SlotDescriptor slotDesc = new SlotDescriptor(new SlotId(5), tupleDesc.getId()); slotDesc.setLabel("`score`"); SlotRef expr = new SlotRef(null, "score"); expr.setDesc(slotDesc); @@ -320,7 +320,7 @@ public void testSlotRefLabelNereidsIsQuery() { public void testSlotRefLabelNotNereids() { // isNereids=false → non-Nereids path, no slot-id suffix regardless of desc TupleDescriptor tupleDesc = new TupleDescriptor(new TupleId(0)); - SlotDescriptor slotDesc = new SlotDescriptor(new SlotId(7), tupleDesc); + SlotDescriptor slotDesc = new SlotDescriptor(new SlotId(7), tupleDesc.getId()); slotDesc.setLabel("`price`"); SlotRef expr = new SlotRef(null, "price"); expr.setDesc(slotDesc); @@ -349,7 +349,7 @@ public void testSlotRefNoLabelNoDesc() { public void testSlotRefDescWithSourceExprs() { // label=null, desc has sourceExprs → " expr visitor result" TupleDescriptor tupleDesc = new TupleDescriptor(new TupleId(0)); - SlotDescriptor slotDesc = new SlotDescriptor(new SlotId(2), tupleDesc); + SlotDescriptor slotDesc = new SlotDescriptor(new SlotId(2), tupleDesc.getId()); slotDesc.setSourceExpr(new IntLiteral(42L)); SlotRef expr = new SlotRef(null, "x"); @@ -369,7 +369,7 @@ public void testSlotRefDescWithSourceExprs() { public void testSlotRefDescNoSourceExprs() { // label=null, desc has no sourceExprs → "" TupleDescriptor tupleDesc = new TupleDescriptor(new TupleId(0)); - SlotDescriptor slotDesc = new SlotDescriptor(new SlotId(4), tupleDesc); + SlotDescriptor slotDesc = new SlotDescriptor(new SlotId(4), tupleDesc.getId()); SlotRef expr = new SlotRef(null, "x"); try { diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/PlanNodeTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/PlanNodeTest.java index a065a186e7e8d6..76395a6b0e8715 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/planner/PlanNodeTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/planner/PlanNodeTest.java @@ -74,7 +74,7 @@ public void testGetPointQueryProjectListFlattensIntermediateProjection() { private static SlotDescriptor createColumnSlot(TupleDescriptor tupleDescriptor, int slotId, String columnName) { - SlotDescriptor slotDescriptor = new SlotDescriptor(new SlotId(slotId), tupleDescriptor); + SlotDescriptor slotDescriptor = new SlotDescriptor(new SlotId(slotId), tupleDescriptor.getId()); slotDescriptor.setColumn(new Column(columnName, Type.BIGINT)); slotDescriptor.setLabel(columnName); tupleDescriptor.addSlot(slotDescriptor); @@ -83,7 +83,7 @@ private static SlotDescriptor createColumnSlot(TupleDescriptor tupleDescriptor, private static SlotDescriptor createExprSlot(TupleDescriptor tupleDescriptor, int slotId, String label) { - SlotDescriptor slotDescriptor = new SlotDescriptor(new SlotId(slotId), tupleDescriptor); + SlotDescriptor slotDescriptor = new SlotDescriptor(new SlotId(slotId), tupleDescriptor.getId()); slotDescriptor.setType(Type.BIGINT); slotDescriptor.setLabel(label); tupleDescriptor.addSlot(slotDescriptor);