Skip to content

Commit

Permalink
[refactor](Nereids): remove withLogicalProperties & check children si…
Browse files Browse the repository at this point in the history
…ze (apache#21563)
  • Loading branch information
jackwener authored Jul 6, 2023
1 parent fba3ae9 commit 79221a5
Show file tree
Hide file tree
Showing 78 changed files with 45 additions and 466 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
Optional.of(getLogicalProperties()), child());
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new UnboundOlapTableSink<>(nameParts, colNames, hints, partitions, groupExpression,
logicalProperties, child());
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
return new UnboundOneRowRelation(id, projects, groupExpression, Optional.of(logicalPropertiesSupplier.get()));
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new UnboundOneRowRelation(id, projects, Optional.empty(), logicalProperties);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
isTempPart, hints);
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new UnboundRelation(id, nameParts, Optional.empty(), logicalProperties, partNames,
isTempPart, hints);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
Optional.of(getLogicalProperties()));
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new UnboundTVFRelation(id, functionName, properties, Optional.empty(), logicalProperties);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
throw new RuntimeException("multiJoin can't invoke withGroupExpression");
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
throw new RuntimeException("multiJoin can't invoke withLogicalProperties");
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ public LogicalProject<Plan> visitLogicalProject(LogicalProject<? extends Plan> p

@Override
public LogicalOlapScan visitLogicalOlapScan(LogicalOlapScan scan, Void ctx) {
return scan.withLogicalProperties(Optional.empty());
return (LogicalOlapScan) scan.withGroupExprLogicalPropChildren(scan.getGroupExpression(), Optional.empty(),
ImmutableList.of());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
return this;
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return this;
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ public Statistics getStats() {
throw new IllegalStateException("GroupPlan can not invoke getStats()");
}

@Override
public GroupPlan withOutput(List<Slot> output) {
throw new IllegalStateException("GroupPlan can not invoke withOutput()");
}

@Override
public GroupPlan withChildren(List<Plan> children) {
throw new IllegalStateException("GroupPlan can not invoke withChildren()");
Expand All @@ -79,11 +74,6 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
throw new IllegalStateException("GroupPlan can not invoke withGroupExpression()");
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
throw new IllegalStateException("GroupPlan can not invoke withLogicalProperties()");
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,8 @@ default List<Slot> computeOutput() {

String treeString();

default Plan withOutput(List<Slot> output) {
return withLogicalProperties(Optional.of(getLogicalProperties().withOutput(output)));
}

Plan withGroupExpression(Optional<GroupExpression> groupExpression);

Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties);

Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,4 @@ public String treeString() {
public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
throw new RuntimeException("Command do not implement withGroupExpression");
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
throw new RuntimeException("Command do not implement withLogicalProperties");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,10 @@ public LogicalAggregate<Plan> withGroupExpression(Optional<GroupExpression> grou
hasPushed, sourceRepeat, groupExpression, Optional.of(getLogicalProperties()), children.get(0));
}

@Override
public LogicalAggregate<Plan> withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalAggregate<>(groupByExpressions, outputExpressions, normalized, ordinalIsResolved, generated,
hasPushed, sourceRepeat, Optional.empty(), logicalProperties, children.get(0));
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalAggregate<>(groupByExpressions, outputExpressions, normalized, ordinalIsResolved, generated,
hasPushed, sourceRepeat, groupExpression, Optional.of(getLogicalProperties()), children.get(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,10 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
markJoinSlotReference, subCorrespondingConjunct, needAddSubOutputToProjects, left(), right());
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalApply<>(Optional.empty(), logicalProperties,
correlationSlot, subqueryExpr, correlationFilter,
markJoinSlotReference, subCorrespondingConjunct, needAddSubOutputToProjects, left(), right());
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 2);
return new LogicalApply<>(groupExpression, logicalProperties, correlationSlot, subqueryExpr, correlationFilter,
markJoinSlotReference, subCorrespondingConjunct, needAddSubOutputToProjects, children.get(0),
children.get(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,11 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
groupExpression, Optional.of(getLogicalProperties()), child());
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalAssertNumRows<>(assertNumRowsElement, Optional.empty(), logicalProperties, child());
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
return new LogicalAssertNumRows<>(assertNumRowsElement,
groupExpression, logicalProperties, children.get(0));
Preconditions.checkArgument(children.size() == 1);
return new LogicalAssertNumRows<>(assertNumRowsElement, groupExpression, logicalProperties, children.get(0));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,10 @@ public LogicalCTE<CHILD_TYPE> withGroupExpression(Optional<GroupExpression> grou
registered, cteNameToId);
}

@Override
public LogicalCTE<CHILD_TYPE> withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalCTE<>(aliasQueries, Optional.empty(), logicalProperties, child(), registered,
cteNameToId);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(aliasQueries.size() > 0);
return new LogicalCTE<>(aliasQueries, groupExpression, logicalProperties, children.get(0),
registered, cteNameToId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
return new LogicalCTEAnchor<>(groupExpression, Optional.of(getLogicalProperties()), left(), right(), cteId);
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalCTEAnchor<>(groupExpression, logicalProperties, left(), right(), cteId);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,6 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
consumerId, name);
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalCTEConsumer(groupExpression, logicalProperties, cteId,
consumerToProducerOutputMap,
producerToConsumerOutputMap,
consumerId, name);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
projects, rewritten);
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalCTEProducer<>(groupExpression, logicalProperties, child(), cteId,
projects, rewritten);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,10 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
return new LogicalCheckPolicy<>(groupExpression, Optional.of(getLogicalProperties()), child());
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalCheckPolicy<>(Optional.empty(), logicalProperties, child());
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalCheckPolicy<>(groupExpression, logicalProperties, children.get(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
return new LogicalEmptyRelation(projects, groupExpression, Optional.of(logicalPropertiesSupplier.get()));
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalEmptyRelation(projects, Optional.empty(), logicalProperties);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ public LogicalEsScan withGroupExpression(Optional<GroupExpression> groupExpressi
Optional.of(getLogicalProperties()));
}

@Override
public LogicalEsScan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalEsScan(id, (ExternalTable) table, qualifier, groupExpression,
logicalProperties);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ public LogicalExcept withGroupExpression(Optional<GroupExpression> groupExpressi
Optional.of(getLogicalProperties()), children);
}

@Override
public LogicalExcept withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalExcept(qualifier, outputs,
Optional.empty(), logicalProperties, children);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ public LogicalFileScan withGroupExpression(Optional<GroupExpression> groupExpres
Optional.of(getLogicalProperties()), conjuncts);
}

@Override
public LogicalFileScan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalFileScan(id, (ExternalTable) table, qualifier, groupExpression,
logicalProperties, conjuncts);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,10 @@ public LogicalFilter<Plan> withGroupExpression(Optional<GroupExpression> groupEx
return new LogicalFilter<>(conjuncts, groupExpression, Optional.of(getLogicalProperties()), child());
}

@Override
public LogicalFilter<Plan> withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalFilter<>(conjuncts, Optional.empty(), logicalProperties, child());
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalFilter<>(conjuncts, groupExpression, logicalProperties, children.get(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,10 @@ public LogicalGenerate<Plan> withGroupExpression(Optional<GroupExpression> group
groupExpression, Optional.of(getLogicalProperties()), child());
}

@Override
public LogicalGenerate<Plan> withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalGenerate<>(generators, generatorOutput,
Optional.empty(), logicalProperties, child());
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalGenerate<>(generators, generatorOutput, groupExpression, logicalProperties, children.get(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,10 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
return new LogicalHaving<>(conjuncts, groupExpression, Optional.of(getLogicalProperties()), child());
}

@Override
public Plan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalHaving<>(conjuncts, Optional.empty(), logicalProperties, child());
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalHaving<>(conjuncts, groupExpression, logicalProperties, children.get(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ public LogicalIntersect withGroupExpression(Optional<GroupExpression> groupExpre
Optional.of(getLogicalProperties()), children);
}

@Override
public LogicalIntersect withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalIntersect(qualifier, outputs,
Optional.empty(), logicalProperties, children);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ public LogicalJdbcScan withGroupExpression(Optional<GroupExpression> groupExpres
Optional.of(getLogicalProperties()));
}

@Override
public LogicalJdbcScan withLogicalProperties(Optional<LogicalProperties> logicalProperties) {
return new LogicalJdbcScan(id, table, qualifier, groupExpression,
logicalProperties);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Expand Down
Loading

0 comments on commit 79221a5

Please sign in to comment.