-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-38609][table] Make generation of xml plans deterministic #27183
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
Conversation
| * one diff is recorded. | ||
| */ | ||
| private static final Map<Class<?>, DiffRepository> MAP_CLASS_TO_REPOSITORY = new HashMap<>(); | ||
| private static final LoadingCache<Key, DiffRepository> REPOSITORY_CACHE = |
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.
Mostly synced with updates from Calcite version (https://github.com/apache/calcite/blob/main/testkit/src/main/java/org/apache/calcite/test/DiffRepository.java), also fixed some bugs both here and in Calcite, like e.g. apache/calcite#4612
There are still some differences between Flink and Calcite versions however now much less.
Probably need a separate task to try to backport Flink's features to Calcite and drop it from Flink repo
| </Resource> | ||
| </TestCase> | ||
| <TestCase name="testExplainWithAgg[extended=true]"> | ||
| <TestCase name="testExplainWithAgg[extended=false]"> |
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.
Here and all other xml files: were dropped and completely regenerated
| @@ -107,7 +107,7 @@ class IntervalJoinTest extends TableTestBase { | |||
|
|
|||
| /** The time conditions should be an And condition * */ | |||
| @Test | |||
| def testInteravalNotCnfCondition(): Unit = { | |||
| def testIntervalNotCnfCondition(): Unit = { | |||
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.
misprint
| plans.remove(PlanKind.OPT_REL) | ||
| // if there is something else in expected plans, then use it for xml generation if needed | ||
| assertEqualsOrExpand("optimized rel plan", optimizedRelPlan, !plans.isEmpty) |
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.
There are some tests requiring both OPT_REL, OPT_REL_WITH_ADVICE
in order to have both generated in xml, need to put true here if both are present
e40a885 to
38a600e
Compare
twalthr
left a comment
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.
Thanks for further improving our testing infra.
| @@ -1225,16 +1225,23 @@ abstract class TableTestUtilBase(test: TableTestBase, isStreamingMode: Boolean) | |||
| // check whether the sql equals to the expected if the `relNodes` are translated from sql | |||
| assertSqlEqualsOrExpandFunc() | |||
| // check ast plan | |||
| val plans = new util.HashSet[PlanKind](expectedPlans.toSeq.asJava) | |||
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.
Can you put the non-xml changes into a separate commit?
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.
yep, sure, splitted into several commits
…#testWithProjectCaseWhenCorrelate`
| assertThatExceptionOfType(classOf[AssertionError]) | ||
| .isThrownBy(() => util.verifyRelPlan(sqlQuery)) |
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.
Seems since some time it was fixed and this code was continuing throwing exception with a different reason (nothing in xml plans... ). So generated plans for this
| [*Test.xml] | ||
| indent_style = space | ||
| indent_size = 2 |
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.
sync with DiffRepository where indentation is in spaces
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.
Great 👍 Also had this indentation issue when manually updating xmls
gustavodemorais
left a comment
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.
Checked for some tests and the ordering looks good.
Thanks a lot, @snuyanzin. It might be a simple change but for people constantly regenerating plans, this is really useful.
| [*Test.xml] | ||
| indent_style = space | ||
| indent_size = 2 |
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.
Great 👍 Also had this indentation issue when manually updating xmls
twalthr
left a comment
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.
Thanks for this improvement @snuyanzin! LGTM
What is the purpose of the change
The PR is based on [FLINK-38608][table] Drop abandoned plans without related testsThe main idea here is to enable xml plan generation in predictable way (in alphabetical order by test cases within xml).
It means that no need for manual work with copy pasting of generated xml while adding/changing/fixing plans.
Just drop the whole xml, run test and it will regenerate a new version changing only required part instead of reordering everything each time, moreover test will check the order while execution as well.
The downside here: it will trigger to regenerate existing plans, however it will be done only once (in this PR)
Brief change log
plans and DiffRepository (mostly synced with Calcite's version)
Verifying this change
existing tests
Does this pull request potentially affect one of the following parts:
@Public(Evolving): (no)Documentation