[fix](Nereids): when GroupExpr already exists, we need to remove ParentExpression (#18749)
This commit is contained in:
@ -182,7 +182,7 @@ public class GroupExpression {
|
||||
*/
|
||||
public boolean isUnused() {
|
||||
if (isUnused) {
|
||||
Preconditions.checkState(children.isEmpty() || ownerGroup == null);
|
||||
Preconditions.checkState(children.isEmpty() && ownerGroup == null);
|
||||
return true;
|
||||
}
|
||||
Preconditions.checkState(ownerGroup != null);
|
||||
|
||||
@ -427,6 +427,9 @@ public class Memo {
|
||||
if (target != null && !target.getGroupId().equals(existedGroupExpression.getOwnerGroup().getGroupId())) {
|
||||
mergeGroup(existedGroupExpression.getOwnerGroup(), target);
|
||||
}
|
||||
// When we create a GroupExpression, we will add it into ParentExpression of childGroup.
|
||||
// But if it already exists, we should remove it from ParentExpression of childGroup.
|
||||
groupExpression.children().forEach(childGroup -> childGroup.removeParentExpression(groupExpression));
|
||||
return CopyInResult.of(false, existedGroupExpression);
|
||||
}
|
||||
if (target != null) {
|
||||
|
||||
Reference in New Issue
Block a user