Skip to content
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

[FLINK-25128][table] Reorganize table modules and introduce flink-table-planner-loader #18134

Closed
wants to merge 17 commits into from

Conversation

slinkydeveloper
Copy link
Contributor

What is the purpose of the change

The goal of this PR is to allow arbitrary Scala versions in the user API, hiding the Scala version of the planner from the Scala version of the API. This required some changes in the module organization, as described in the changelog. I also included a README to give an overview to table api developers (not for end users) of the new package organization edf7350.

This PR fixes the following issues:

I will open a followup PR to take care of the documentation.

Changelog

  • PlannerBase is now using the class' classloader in order to load the ParserFactory. In case of planner_${scala.version}, this essentially makes no difference, while in case of planner-loader it will try to load first from its own classpath (which is ComponentClassLoader), and then from the parent classpath.
  • Removed flink-table-uber module and replaced with flink-table-api-uber to ship only Java API related packages in a single uber jar.
  • Now flink-table-runtime ships janino and code-splitter in its uber jar
  • flink-table-planner pom has been reworked, removing dependencies shipped by flink-runtime and flink-dist like jackson and commons-lang3, and now it generates 2 uber jars: one is pretty much the same as we ship now on master, and the other, named loader-bundle, is a uber-jar which includes also scala, in order to be used by flink-table-planner-loader
  • Introduce flink-table-planner-loader. This provides an implementation of the factories in org.apache.flink.table.delegation that uses an isolated classloader to load the implementations from flink-table-planner loader-bundle JAR.
  • Rework SQL Client dependencies and remove scala suffix.
  • Rework Flink distribution. Now we ship as separate jars flink-table-api-uber, flink-table-runtime, flink-table-planner-loader and flink-cep in /lib, while we continue to ship flink-table-planner_${scala.version} in /opt, in order to allow users to replace it with flink-table-planner-loader just in case they need it. This is the fundamental change for the user, and will documented in the followup doc PR.
  • Use planner-loader wherever is possible in e2e tests and examples, and included a new test script that swaps the planner in order to check that both jars work fine.

There are a couple of details worth to mention in order to understand all the moving parts of this PR:

  • Some planner dependencies are relocated, others are not, and note that every relocation performed by runtime needs to be performed by planner as well.
  • The ComponentClassLoader used in PlannerModule allows only certain classes to be loaded from its parent classloader. Those are all the classes starting with "org.apache.flink" (which includes relocated dependencies) plus the classes starting with one of the prefixes in ownerClassPath

Verifying this change

A new e2e test has been included to check that both planner-loader and planner_${scala.version} works fine. All the previous e2e tests are now running with planner-loader, whenever is possible.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): yes
  • The public API, i.e., is any changed class annotated with @Public(Evolving): mp

Documentation

  • Does this pull request introduce a new feature? yes
  • If yes, how is the feature documented? Will open a doc PR as followup

@flinkbot
Copy link
Collaborator

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit 5481a24 (Thu Dec 16 14:43:28 UTC 2021)

Warnings:

  • 14 pom.xml files were touched: Check for build and licensing issues.
  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.


The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@flinkbot
Copy link
Collaborator

flinkbot commented Dec 16, 2021

CI report:

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

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 great PR @slinkydeveloper. It looks we are approaching. Here is my first set of feedback.

flink-dist/src/main/assemblies/opt.xml Outdated Show resolved Hide resolved
flink-dist/src/main/assemblies/bin.xml Outdated Show resolved Hide resolved
flink-end-to-end-tests/run-nightly-tests.sh Outdated Show resolved Hide resolved
flink-end-to-end-tests/test-scripts/common.sh Outdated Show resolved Hide resolved

### Notes

No module except `flink-table-planner` should depend on `flink-table-runtime` in production classpath,
Copy link
Contributor

Choose a reason for hiding this comment

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

"depending" is ok but only as provided maybe you can rephrase this paragraph

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I rather prefer to keep it this way, just as a warning to everyone who even remotely thinks to add it as dependency :)

Copy link
Contributor

Choose a reason for hiding this comment

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

But it needs to be added as a dependency. Otherwise you cannot run it in your IDE. Many people have problems with setting up Maven correctly. We should rephrase this to emphasize: provided is fine

Copy link
Contributor Author

@slinkydeveloper slinkydeveloper Dec 22, 2021

Choose a reason for hiding this comment

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

For testing you need to depend on table-planner-loader, not on table-planner. I added a sentence about testing.

flink-table/flink-sql-client/pom.xml Show resolved Hide resolved
flink-table/flink-table-planner-loader/pom.xml Outdated Show resolved Hide resolved
@slinkydeveloper slinkydeveloper force-pushed the FLINK-25128 branch 3 times, most recently from 4fafb3d to ce0be79 Compare December 21, 2021 10:45
…sloader in order to load the ParserFactory. This makes sure that it will try to load first from its own classpath, and then from the parent classpath.

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
…-table-api-java-uber to ship only api related packages in a single uber jar

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
…nt of the table-planner uber jar that includes scala, in order to be used by flink-table-planner-loader

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
… modules

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
…le-runtime, table-planner-loader and cep in lib, while table-planner_${scala.version} in opt.

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
…uffix.

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
…ts and examples

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
…enever is necessary and add a new e2e test to check both planners work correctly.

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
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.

Awesome work @slinkydeveloper. This change will help users a lot.

flink-examples/flink-examples-table/pom.xml Outdated Show resolved Hide resolved
flink-table/README.md Outdated Show resolved Hide resolved
flink-table/README.md Outdated Show resolved Hide resolved
flink-table/README.md Outdated Show resolved Hide resolved
flink-table/README.md Outdated Show resolved Hide resolved
flink-table/flink-table-planner/pom.xml Outdated Show resolved Hide resolved
<include>org.scala-lang.modules:scala-parser-combinators_${scala.binary.version}</include>

<!-- ReflectionsUtil -->
<include>org.reflections:reflections</include>
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this only used for tests? What is it used for? JSON plan?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check ReflectionsUtil. It's used for the JSON plan but perhaps can be removed (not in this PR though)

<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not provided anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, for this one I can remove it as we pull it from api-java-bridge

flink-table/flink-table-runtime/pom.xml Outdated Show resolved Hide resolved
flink-table/flink-table-runtime/pom.xml Outdated Show resolved Hide resolved
Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
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.

LGTM given the build turns green 🥳

…lasspath

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
…ons with runtime logic in runtime

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
…ct classloader

Signed-off-by: slinkydeveloper <francescoguard@gmail.com>
twalthr pushed a commit to twalthr/flink that referenced this pull request Dec 30, 2021
twalthr pushed a commit to twalthr/flink that referenced this pull request Dec 30, 2021
twalthr pushed a commit to twalthr/flink that referenced this pull request Dec 30, 2021
@twalthr twalthr closed this in fdc53e7 Dec 30, 2021
niklassemmler pushed a commit to niklassemmler/flink that referenced this pull request Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants