Skip to content

Conversation

@snuyanzin
Copy link
Contributor

@snuyanzin snuyanzin commented Nov 2, 2025

What is the purpose of the change

The PR is based on [FLINK-38608][table] Drop abandoned plans without related tests
The 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:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (no)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (no)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? ( no)
  • If yes, how is the feature documented? (not applicable)

* one diff is recorded.
*/
private static final Map<Class<?>, DiffRepository> MAP_CLASS_TO_REPOSITORY = new HashMap<>();
private static final LoadingCache<Key, DiffRepository> REPOSITORY_CACHE =
Copy link
Contributor Author

@snuyanzin snuyanzin Nov 2, 2025

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]">
Copy link
Contributor Author

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 = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misprint

Comment on lines 1236 to 1238
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)
Copy link
Contributor Author

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

@flinkbot
Copy link
Collaborator

flinkbot commented Nov 2, 2025

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@snuyanzin snuyanzin force-pushed the flink38609 branch 2 times, most recently from e40a885 to 38a600e Compare November 3, 2025 09:25
Copy link
Contributor

@twalthr twalthr left a 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)
Copy link
Contributor

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?

Copy link
Contributor Author

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

Comment on lines -158 to -159
assertThatExceptionOfType(classOf[AssertionError])
.isThrownBy(() => util.verifyRelPlan(sqlQuery))
Copy link
Contributor Author

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

Comment on lines +274 to +276
[*Test.xml]
indent_style = space
indent_size = 2
Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor

@gustavodemorais gustavodemorais left a 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.

Comment on lines +274 to +276
[*Test.xml]
indent_style = space
indent_size = 2
Copy link
Contributor

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

Copy link
Contributor

@twalthr twalthr left a 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

@snuyanzin snuyanzin closed this in fd273a5 Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants