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-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE #17155

Closed
wants to merge 3 commits into from
Closed

[FLINK-19883][table] Support 'IF EXISTS' in DDL for ALTER TABLE #17155

wants to merge 3 commits into from

Conversation

SteNicholas
Copy link
Member

What is the purpose of the change

ALTER TABLE does not seem to support the IF EXISTS part in the DDL, but the corresponding methods Catalog#renameTable and Catalog#alterTable do support it. Flink DDL should support IF EXISTS in DDL for ALTER TABLE.

Brief change log

  • Add the IF EXISTS syntax support for the ALTER TABLE DDL.

Verifying this change

  • SqlToOperationConverterTest, CatalogTableITCase and table.q add the tests for ALTER TABLE IF EXISTS syntax.

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

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

Documentation

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

@flinkbot
Copy link
Collaborator

flinkbot commented Sep 6, 2021

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 a89b8c4 (Mon Sep 06 05:43:28 UTC 2021)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!
  • This pull request references an unassigned Jira ticket. According to the code contribution guide, tickets need to be assigned before starting with the implementation work.

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 Sep 6, 2021

CI report:

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

Copy link
Contributor

@Airblader Airblader 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 picking this up. I gave this a first round of review! :-)

@SteNicholas
Copy link
Member Author

@wuchong @Airblader , I have addressed the comments mentioned above. Please help to review again.

public class AlterTableOptionsOperation extends AlterTableOperation {
private final CatalogTable catalogTable;
private final Map<String, String> tableOptions;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still not really happy with this; now we added redundant information for the sake of the summary string, but this information isn't actually used by CatalogManager to alter the table.

In principle I think this class shouldn't hold a CatalogTable at all, but rather only an identifier (which it already does from its superclass) and the new options to be added. TableEnvironmentImpl#executeInternal then just looks up the table when needed (as it already does for some other operations).

Happy to hear someone else's thoughts on this as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Airblader , the CatalogTable isn't hold only by AlterTableOptionsOperation. Other operations like AlterTableSchemaOperation also hold the CatalogTable.
IMO, the converter between the SQL and operation should not pass the CatalogTable. The CatalogTable is looked up when calling TableEnvironmentImpl#executeInternal. But the changes could be pushed another PR to unify for updating.
cc @wuchong

Copy link
Contributor

@Airblader Airblader Sep 8, 2021

Choose a reason for hiding this comment

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

Yes, other operations do that, too, and probably shouldn't do it either. The design of operations needs to be improved overall, because both the operations and the converter contain way too much logic. I think it would be good to improve this for this operation with this PR, because we kind of need it. Otherwise we'd have either incorrectness or redundancy, and both would be a worse situation than before.

I don't think it's a big change to fix this here. It's a pretty small change to just look up the table in TableEnvironmentImpl instead of passing it to the operation during the conversion.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Airblader , OK, I would like to change for this.

@lsyldliu
Copy link
Contributor

lsyldliu commented Apr 2, 2022

Thanks for your contribution @SteNicholas, Can you continue to finish this work?

@SteNicholas
Copy link
Member Author

Thanks for your contribution @SteNicholas, Can you continue to finish this work?

@lsyldliu, thanks for the reminder. I will update this pull request this week. Sorry for the delay to update.

@LadyForest
Copy link
Contributor

Thanks for your contribution @SteNicholas, Can you continue to finish this work?

@lsyldliu, thanks for the reminder. I will update this pull request this week. Sorry for the delay to update.

Hi @SteNicholas, would you like to continue this task?

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants