Skip to content

Commit

Permalink
[refactor](Nereids): add check
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwener committed Jul 6, 2023
1 parent 62fe0f3 commit 7582add
Show file tree
Hide file tree
Showing 32 changed files with 44 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ public LogicalAggregate<Plan> withGroupExpression(Optional<GroupExpression> grou
@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 @@ -218,6 +218,7 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
@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 @@ -107,8 +107,8 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
@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 @@ -148,6 +148,7 @@ public LogicalCTE<CHILD_TYPE> withGroupExpression(Optional<GroupExpression> grou
@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 @@ -102,6 +102,7 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
@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 @@ -129,6 +129,7 @@ public LogicalFilter<Plan> withGroupExpression(Optional<GroupExpression> groupEx
@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 @@ -93,6 +93,7 @@ public LogicalGenerate<Plan> withGroupExpression(Optional<GroupExpression> group
@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 @@ -83,6 +83,7 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
@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 @@ -94,26 +94,14 @@ public LogicalJoin(
Optional.empty(), Optional.empty(), leftChild, rightChild);
}

public LogicalJoin(
JoinType joinType,
List<Expression> hashJoinConjuncts,
List<Expression> otherJoinConjuncts,
JoinHint hint,
Optional<MarkJoinSlotReference> markJoinSlotReference,
List<Plan> children) {
this(joinType, hashJoinConjuncts,
otherJoinConjuncts, hint, markJoinSlotReference,
Optional.empty(), Optional.empty(), children);
}

/**
* Just use in withXXX method.
*/
private LogicalJoin(JoinType joinType, List<Expression> hashJoinConjuncts, List<Expression> otherJoinConjuncts,
JoinHint hint, Optional<MarkJoinSlotReference> markJoinSlotReference,
Optional<GroupExpression> groupExpression, Optional<LogicalProperties> logicalProperties,
List<Plan> children, JoinReorderContext joinReorderContext) {
super(PlanType.LOGICAL_JOIN, groupExpression, logicalProperties, children);
LEFT_CHILD_TYPE leftChild, RIGHT_CHILD_TYPE rightChild, JoinReorderContext joinReorderContext) {
super(PlanType.LOGICAL_JOIN, groupExpression, logicalProperties, leftChild, rightChild);
this.joinType = Objects.requireNonNull(joinType, "joinType can not be null");
this.hashJoinConjuncts = ImmutableList.copyOf(hashJoinConjuncts);
this.otherJoinConjuncts = ImmutableList.copyOf(otherJoinConjuncts);
Expand All @@ -140,23 +128,6 @@ private LogicalJoin(
this.markJoinSlotReference = markJoinSlotReference;
}

private LogicalJoin(
JoinType joinType,
List<Expression> hashJoinConjuncts,
List<Expression> otherJoinConjuncts,
JoinHint hint,
Optional<MarkJoinSlotReference> markJoinSlotReference,
Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties,
List<Plan> children) {
super(PlanType.LOGICAL_JOIN, groupExpression, logicalProperties, children);
this.joinType = Objects.requireNonNull(joinType, "joinType can not be null");
this.hashJoinConjuncts = ImmutableList.copyOf(hashJoinConjuncts);
this.otherJoinConjuncts = ImmutableList.copyOf(otherJoinConjuncts);
this.hint = Objects.requireNonNull(hint, "hint can not be null");
this.markJoinSlotReference = markJoinSlotReference;
}

public List<Expression> getOtherJoinConjuncts() {
return otherJoinConjuncts;
}
Expand Down Expand Up @@ -281,20 +252,21 @@ public RIGHT_CHILD_TYPE right() {
public LogicalJoin<Plan, Plan> withChildren(List<Plan> children) {
Preconditions.checkArgument(children.size() == 2);
return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, markJoinSlotReference,
Optional.empty(), Optional.empty(), children, joinReorderContext);
Optional.empty(), Optional.empty(), children.get(0), children.get(1), joinReorderContext);
}

@Override
public LogicalJoin<Plan, Plan> withGroupExpression(Optional<GroupExpression> groupExpression) {
return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, markJoinSlotReference,
groupExpression, Optional.of(getLogicalProperties()), children, joinReorderContext);
groupExpression, Optional.of(getLogicalProperties()), left(), right(), joinReorderContext);
}

@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 2);
return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, markJoinSlotReference,
groupExpression, logicalProperties, children, joinReorderContext);
groupExpression, logicalProperties, children.get(0), children.get(1), joinReorderContext);
}

public LogicalJoin<Plan, Plan> withChildrenNoContext(Plan left, Plan right) {
Expand All @@ -305,7 +277,7 @@ public LogicalJoin<Plan, Plan> withChildrenNoContext(Plan left, Plan right) {
public LogicalJoin<Plan, Plan> withJoinConjuncts(
List<Expression> hashJoinConjuncts, List<Expression> otherJoinConjuncts) {
return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts,
hint, markJoinSlotReference, children);
hint, markJoinSlotReference, left(), right());
}

public LogicalJoin<Plan, Plan> withHashJoinConjunctsAndChildren(
Expand All @@ -323,7 +295,7 @@ public LogicalJoin<Plan, Plan> withConjunctsChildren(List<Expression> hashJoinCo

public LogicalJoin<Plan, Plan> withJoinType(JoinType joinType) {
return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint,
markJoinSlotReference, children);
markJoinSlotReference, left(), right());
}

public LogicalJoin<Plan, Plan> withTypeChildren(JoinType joinType, Plan left, Plan right) {
Expand All @@ -333,7 +305,7 @@ public LogicalJoin<Plan, Plan> withTypeChildren(JoinType joinType, Plan left, Pl

public LogicalJoin<Plan, Plan> withOtherJoinConjuncts(List<Expression> otherJoinConjuncts) {
return new LogicalJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint,
markJoinSlotReference, children);
markJoinSlotReference, left(), right());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalLimit<>(limit, offset, phase, groupExpression, logicalProperties, children.get(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public LogicalPartitionTopN<Plan> withGroupExpression(Optional<GroupExpression>
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalPartitionTopN<>(function, partitionKeys, orderKeys, hasGlobalLimit, partitionLimit,
groupExpression, logicalProperties, children.get(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public LogicalProject<Plan> withGroupExpression(Optional<GroupExpression> groupE
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalProject<>(projects, excepts, canEliminate,
groupExpression, logicalProperties, children.get(0), isDistinct);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public LogicalRepeat<CHILD_TYPE> withGroupExpression(Optional<GroupExpression> g
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalRepeat<>(groupingSets, outputExpressions, groupExpression, logicalProperties,
children.get(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ public LogicalSelectHint(Map<String, SelectHint> hints, CHILD_TYPE child) {
this(hints, Optional.empty(), Optional.empty(), child);
}

public LogicalSelectHint(Map<String, SelectHint> hints,
Optional<LogicalProperties> logicalProperties, CHILD_TYPE child) {
this(hints, Optional.empty(), logicalProperties, child);
}

/**
* LogicalSelectHint's full parameter constructor.
* @param hints hint maps, key is hint name, e.g. 'SET_VAR', and value is parameter pairs, e.g. query_time=100
Expand Down Expand Up @@ -95,6 +90,7 @@ public LogicalSelectHint<CHILD_TYPE> withGroupExpression(Optional<GroupExpressio
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalSelectHint<>(hints, groupExpression, logicalProperties, children.get(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public LogicalSort<Plan> withGroupExpression(Optional<GroupExpression> groupExpr
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalSort<>(orderKeys, groupExpression, logicalProperties, children.get(0),
normalized);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public LogicalSubQueryAlias<CHILD_TYPE> withGroupExpression(Optional<GroupExpres
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalSubQueryAlias<>(qualifier, columnAliases, groupExpression, logicalProperties,
children.get(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public LogicalTopN<Plan> withGroupExpression(Optional<GroupExpression> groupExpr
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalTopN<>(orderKeys, limit, offset, groupExpression, logicalProperties, children.get(0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public Plan withGroupExpression(Optional<GroupExpression> groupExpression) {
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new LogicalWindow<>(windowExpressions, isChecked, groupExpression, logicalProperties, children.get(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public PhysicalAssertNumRows<CHILD_TYPE> withGroupExpression(Optional<GroupExpre
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new PhysicalAssertNumRows<>(assertNumRowsElement, groupExpression,
logicalProperties.get(), physicalProperties, statistics, children.get(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public PhysicalCTEAnchor<Plan, Plan> withGroupExpression(Optional<GroupExpressio
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 2);
return new PhysicalCTEAnchor<>(cteId, groupExpression, logicalProperties.get(), children.get(0),
children.get(1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public PhysicalDistribute<CHILD_TYPE> withGroupExpression(Optional<GroupExpressi
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new PhysicalDistribute<>(distributionSpec, groupExpression,
logicalProperties.get(), children.get(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public PhysicalFilter<CHILD_TYPE> withGroupExpression(Optional<GroupExpression>
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new PhysicalFilter<>(conjuncts, groupExpression, logicalProperties.get(), children.get(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public PhysicalGenerate<CHILD_TYPE> withGroupExpression(Optional<GroupExpression
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new PhysicalGenerate<>(generators, generatorOutput,
groupExpression, logicalProperties.get(), children.get(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ public PhysicalHashAggregate<CHILD_TYPE> withGroupExpression(Optional<GroupExpre
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new PhysicalHashAggregate<>(groupByExpressions, outputExpressions, partitionExpressions,
aggregateParam, maybeUsingStream, groupExpression, logicalProperties.get(),
requireProperties, children.get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public PhysicalHashJoin<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE> withGroupExpression(
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 2);
return new PhysicalHashJoin<>(joinType, hashJoinConjuncts, otherJoinConjuncts, hint, markJoinSlotReference,
groupExpression, logicalProperties.get(), children.get(0), children.get(1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public PhysicalLimit<CHILD_TYPE> withGroupExpression(Optional<GroupExpression> g
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 1);
return new PhysicalLimit<>(limit, offset, phase, groupExpression, logicalProperties.get(), children.get(0));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public PhysicalNestedLoopJoin<LEFT_CHILD_TYPE, RIGHT_CHILD_TYPE> withGroupExpres
@Override
public Plan withGroupExprLogicalPropChildren(Optional<GroupExpression> groupExpression,
Optional<LogicalProperties> logicalProperties, List<Plan> children) {
Preconditions.checkArgument(children.size() == 2);
return new PhysicalNestedLoopJoin<>(joinType,
hashJoinConjuncts, otherJoinConjuncts, markJoinSlotReference, groupExpression,
logicalProperties.get(), children.get(0), children.get(1));
Expand Down
Loading

0 comments on commit 7582add

Please sign in to comment.