Skip to content

Conversation

@twalthr
Copy link
Contributor

@twalthr twalthr commented Aug 7, 2019

What is the purpose of the change

This fixes the currently broken TableEnvironment.connect() API by reworking the descriptor class hierarchy. TableDescriptor now contains most of the logic and ConnectTableDescriptor is the return type of table environments (expect for legacy Batch/StreamTableDescriptors).

The API is still mostly source code compatible.

Brief change log

  • Return ConnectTableDescriptor
  • Merge ConnectorFormatDescriptor, StreamableDescriptor, and TableDescriptor
  • Merge RegistrableDescriptor and ConnectTableDescriptor

Verifying this change

A new TableEnvironmentTest tests the implementation.

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): yes
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, 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? JavaDocs

@flinkbot
Copy link
Collaborator

flinkbot commented Aug 7, 2019

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 763fa08 (Thu Aug 08 15:38:33 UTC 2019)

Warnings:

  • 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.

Details
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 Aug 7, 2019

CI report:

Copy link
Contributor

@dawidwys dawidwys left a 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();
Copy link
Contributor

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() {
Copy link
Contributor

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();

Copy link
Contributor

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

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

Copy link
Contributor Author

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

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

@dawidwys dawidwys Aug 8, 2019

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?

Copy link
Contributor Author

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() {
Copy link
Contributor

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.

Copy link
Contributor

@dawidwys dawidwys 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 the update @twalthr. I think it's good to be merged now.

@twalthr
Copy link
Contributor Author

twalthr commented Aug 8, 2019

Merging...

asfgit pushed a commit that referenced this pull request Aug 8, 2019
@asfgit asfgit closed this in d544d30 Aug 8, 2019
becketqin pushed a commit to becketqin/flink that referenced this pull request Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants