-
Notifications
You must be signed in to change notification settings - Fork 3.7k
(Refactor)[Nereids] Combine operator and plan #10786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8af696f
6877045
ddaa70d
0cfdba4
0ec1c82
8157baa
abc66cb
acabe12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,38 +19,51 @@ | |
|
|
||
| import org.apache.doris.nereids.analyzer.identifier.TableIdentifier; | ||
| import org.apache.doris.nereids.exceptions.UnboundException; | ||
| import org.apache.doris.nereids.operators.OperatorType; | ||
| import org.apache.doris.nereids.operators.plans.logical.LogicalLeafOperator; | ||
| import org.apache.doris.nereids.memo.GroupExpression; | ||
| import org.apache.doris.nereids.properties.LogicalProperties; | ||
| import org.apache.doris.nereids.properties.UnboundLogicalProperties; | ||
| import org.apache.doris.nereids.trees.expressions.Expression; | ||
| import org.apache.doris.nereids.trees.expressions.Slot; | ||
| import org.apache.doris.nereids.trees.plans.Plan; | ||
| import org.apache.doris.nereids.trees.plans.PlanType; | ||
| import org.apache.doris.nereids.trees.plans.logical.LogicalLeaf; | ||
| import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; | ||
| import org.apache.doris.nereids.util.Utils; | ||
|
|
||
| import com.google.common.collect.Lists; | ||
| import org.apache.commons.lang3.StringUtils; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| /** | ||
| * Represent a relation plan node that has not been bound. | ||
| */ | ||
| public class UnboundRelation extends LogicalLeafOperator implements Unbound { | ||
| public class UnboundRelation extends LogicalLeaf implements Unbound { | ||
| private final List<String> nameParts; | ||
|
|
||
| public UnboundRelation(List<String> nameParts) { | ||
| super(OperatorType.LOGICAL_UNBOUND_RELATION); | ||
| this(nameParts, Optional.empty(), Optional.empty()); | ||
| } | ||
|
|
||
| public UnboundRelation(List<String> nameParts, Optional<GroupExpression> groupExpression, | ||
| Optional<LogicalProperties> logicalProperties) { | ||
| super(PlanType.LOGICAL_UNBOUND_RELATION, groupExpression, logicalProperties); | ||
| this.nameParts = nameParts; | ||
| } | ||
|
|
||
| public UnboundRelation(TableIdentifier identifier) { | ||
| this(identifier, Optional.empty(), Optional.empty()); | ||
| } | ||
|
|
||
| /** | ||
| * Constructor for UnboundRelation. | ||
| * | ||
| * @param identifier relation identifier | ||
| */ | ||
| public UnboundRelation(TableIdentifier identifier) { | ||
| super(OperatorType.LOGICAL_UNBOUND_RELATION); | ||
| public UnboundRelation(TableIdentifier identifier, Optional<GroupExpression> groupExpression, | ||
| Optional<LogicalProperties> logicalProperties) { | ||
| super(PlanType.LOGICAL_UNBOUND_RELATION, groupExpression, logicalProperties); | ||
| this.nameParts = Lists.newArrayList(); | ||
| if (identifier.getDatabaseName().isPresent()) { | ||
| nameParts.add(identifier.getDatabaseName().get()); | ||
|
|
@@ -72,6 +85,16 @@ public LogicalProperties computeLogicalProperties(Plan... inputs) { | |
| return new UnboundLogicalProperties(); | ||
| } | ||
|
|
||
| @Override | ||
| public Plan withGroupExpression(Optional<GroupExpression> groupExpression) { | ||
| return new UnboundRelation(nameParts, groupExpression, Optional.of(logicalProperties)); | ||
| } | ||
|
|
||
| @Override | ||
| public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) { | ||
| return new UnboundRelation(nameParts, Optional.empty(), logicalProperties); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. groupexpression should use original one?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when the plan is changed, the groupExpression must be clear to tell the memo: I create a new plan, don't skip copyIn. |
||
| } | ||
|
|
||
| @Override | ||
| public List<Slot> computeOutput() { | ||
| throw new UnboundException("output"); | ||
|
|
@@ -82,6 +105,11 @@ public String toString() { | |
| return "UnresolvedRelation" + "(" + StringUtils.join(nameParts, ".") + ")"; | ||
| } | ||
|
|
||
| @Override | ||
| public <R, C> R accept(PlanVisitor<R, C> visitor, C context) { | ||
| return visitor.visitUnboundRelation(this, context); | ||
| } | ||
|
|
||
| @Override | ||
| public List<Expression> getExpressions() { | ||
| throw new UnsupportedOperationException(this.getClass().getSimpleName() + " don't support getExpression()"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix checkstyle. and private enum DateLiteralType's constructor is also private, so can be omitted