-
Notifications
You must be signed in to change notification settings - Fork 13.9k
[FLINK-13600][table] Rework TableEnvironment.connect() class hierarchy #9382
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
|
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit 763fa08 (Thu Aug 08 15:38:33 UTC 2019) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. DetailsThe 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 commandsThe @flinkbot bot supports the following commands:
|
dawidwys
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.
I think this is a good step to make the TableDescriptors simpler.
As we are reworking the hierarchy I think it makes sense to fix the contract of TableDescriptor#toProperties & ConnectTableDescriptor#toProperties as part of this.
| private Optional<FormatDescriptor> formatDescriptor = Optional.empty(); | ||
| private final boolean isGeneric; | ||
|
|
||
| private Optional<Statistics> statisticsDescriptor = Optional.empty(); |
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.
I know this would be unrelated change, but how about we drop the statisticsDescriptor & metadataDescriptor. They cannot be set, they are always empty, so they are effectively useless. Moreover they use Optional as a class field which is against our code style guidelines.
| * Converts this descriptor into a set of properties. | ||
| */ | ||
| @Override | ||
| public Map<String, String> toProperties() { |
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.
How about we make this method a bit safer to extend. Right now it adds implicit contract that you have to call super.toProperties in a child class.
Maybe we could change it to:
public final Map<String, String> toProperties() {
...
properties.asMap().putAll(extraProperties());
}
protected abstract Map<String, String> extraProperties();
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.
I just saw it's done this way already for FormatDescriptor
| implements StreamableDescriptor<StreamTableDescriptor> { | ||
|
|
||
| private Optional<String> updateMode = Optional.empty(); | ||
| public final class StreamTableDescriptor extends ConnectTableDescriptor { |
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.
Probably we can't do it because of backwards compatibility, but I will put it here anyway.
Do we even need the StreamTableDescriptor? It has no additional methods compared to ConnectTableDescriptor
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.
Backwards compatibility is the answer. I will add a comment to the class.
| this.planner = planner; | ||
| } | ||
|
|
||
| public static TableEnvironmentMock getInstance(boolean isStreamingMode) { |
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.
nit: getInstance(Boolean) -> getStreamingInstance + getBatchInstance
| */ | ||
| @PublicEvolving | ||
| public abstract class TableDescriptor extends DescriptorBase { | ||
| public abstract class TableDescriptor<D extends TableDescriptor<D>> extends DescriptorBase { |
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.
Do we need both TableDescriptor & ConnectTableDescriptor?
There is only a single descriptor that extends from TableDescriptor directly (and to be honest I couldn't find any reasonable usage of it in a production code). Moreover I think the sole purpose of a descriptor is to register it somewhere. Isn't it?
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.
TableDescriptor is used in CatalogTableBuilder. The main reason of this class is the generic that is not present in ConnectTableDescriptor.
| * Converts this descriptor into a set of properties. | ||
| */ | ||
| @Override | ||
| public Map<String, String> toProperties() { |
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.
The same problem as for ConnectTableDescriptor. Adds implicit contract.
dawidwys
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 the update @twalthr. I think it's good to be merged now.
|
Merging... |
What is the purpose of the change
This fixes the currently broken
TableEnvironment.connect()API by reworking the descriptor class hierarchy.TableDescriptornow contains most of the logic andConnectTableDescriptoris the return type of table environments (expect for legacy Batch/StreamTableDescriptors).The API is still mostly source code compatible.
Brief change log
ConnectTableDescriptorVerifying this change
A new
TableEnvironmentTesttests the implementation.Does this pull request potentially affect one of the following parts:
@Public(Evolving): yesDocumentation