[fix](Nereids) Compare plan with their output rather than string in UnrankTest (#17698)

After adding a unique ID, the unRankTest fail because each plan has a different ID in the string.
To avoid the effect of unique ID, Compare the plan with the output rather than the string
This commit is contained in:
谢健
2023-03-14 11:10:06 +08:00
committed by GitHub
parent 5b39fa9843
commit 3a97190661
2 changed files with 15 additions and 1 deletions

View File

@ -61,7 +61,7 @@ public class RankTest extends TPCHTestBase {
.rewrite()
.optimize()
.getBestPlanTree(PhysicalProperties.GATHER);
Assertions.assertEquals(plan1.treeString(), plan2.treeString());
Assertions.assertTrue(PlanChecker.isPlanEqualWithoutID(plan1, plan2));
}
}
}

View File

@ -596,4 +596,18 @@ public class PlanChecker {
return this;
}
public static boolean isPlanEqualWithoutID(Plan plan1, Plan plan2) {
if (plan1.arity() != plan2.arity()
|| !plan1.getOutput().equals(plan2.getOutput()) || plan1.getClass() != plan2.getClass()) {
System.out.println(plan1);
System.out.println(plan2);
return false;
}
for (int i = 0; i < plan1.arity(); i++) {
if (!isPlanEqualWithoutID(plan1.child(i), plan2.child(i))) {
return false;
}
}
return true;
}
}