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-31426][table] Upgrade the deprecated UniqueConstraint to the n… #22301

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

xiaochen-zhou
Copy link

@xiaochen-zhou xiaochen-zhou commented Mar 29, 2023

What is the purpose of the change

Upgrade the deprecated UniqueConstraint to the new one

Brief change log

  • Upgrade the deprecated UniqueConstraint to the new one

Verifying this change

This change is already covered by existing tests, such as UniqueConstraintTest.

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, Kubernetes/Yarn, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (no)

@flinkbot
Copy link
Collaborator

flinkbot commented Mar 29, 2023

CI report:

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

@xiaochen-zhou
Copy link
Author

xiaochen-zhou commented Mar 29, 2023

can you spare some precious time to review? Thanks very much @Aitozi @wuchong

Copy link
Contributor

@Aitozi Aitozi left a comment

Choose a reason for hiding this comment

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

@clownxc Thanks for your work. I just left one minor comments.

BTW, the CI failed.

* org.apache.flink.table.catalog.UniqueConstraint}.
*/
@Deprecated
@PublicEvolving
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 afraid we can't directly remove this @PublicEvolving API. CC @luoyuxia

Copy link
Contributor

@luoyuxia luoyuxia Mar 30, 2023

Choose a reason for hiding this comment

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

+1. Share same concern. We must be cautious about dropping @PublicEvolving api.

Copy link
Author

Choose a reason for hiding this comment

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

+1. Share same concern. We must be cautious about dropping @PublicEvolving api.

Thank you so much for review. I will rollback '@ PublicEvolving' api Delete operation @luoyuxia @Aitozi

@xiaochen-zhou
Copy link
Author

@clownxc Thanks for your work. I just left one minor comments.

BTW, the CI failed.

Thank you so much for review. The reason for the CI failure is “You have 1 Checkstyle violation”. I will modify the code style to comply with Flink‘s rewuirements

@@ -328,7 +328,7 @@ void testPrimaryKeyPrinting() {
+ " |-- f0: BIGINT NOT NULL\n"
+ " |-- f1: STRING NOT NULL\n"
+ " |-- f2: DOUBLE NOT NULL\n"
+ " |-- CONSTRAINT pk PRIMARY KEY (f0, f2)\n");
+ " |-- CONSTRAINT `pk` PRIMARY KEY (`f0`, `f2`) NOT ENFORCED\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this changed ?

Copy link
Author

Choose a reason for hiding this comment

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

there are some minor differences between the new and old APIs

public final String asSummaryString() {
        return String.format(
                "CONSTRAINT %s %s (%s)%s",
                EncodingUtils.escapeIdentifier(getName()),
                getTypeString(),
                columns.stream()
                        .map(EncodingUtils::escapeIdentifier)
                        .collect(Collectors.joining(", ")),
                isEnforced() ? "" : " NOT ENFORCED");
  }

The method escapeIdentifier of the new api adds a symbol `` to each field

    public static String escapeIdentifier(String s) {
        return "`" + escapeBackticks(s) + "`";
    }

@Aitozi

Copy link
Author

Choose a reason for hiding this comment

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

this is the deprecated UniqueConstraint

    public final String asSummaryString() {
        final String typeString;
        switch (getType()) {
            case PRIMARY_KEY:
                typeString = "PRIMARY KEY";
                break;
            case UNIQUE_KEY:
                typeString = "UNIQUE";
                break;
            default:
                throw new IllegalStateException("Unknown key type: " + getType());
        }

        return String.format(
                "CONSTRAINT %s %s (%s)", getName(), typeString, String.join(", ", columns));
    }

Copy link
Contributor

@Aitozi Aitozi left a comment

Choose a reason for hiding this comment

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

LGTM +1

@xiaochen-zhou
Copy link
Author

I applied the suggested code changes.Can you please do another review @luoyuxia

@luoyuxia luoyuxia self-assigned this Apr 9, 2023
@luoyuxia
Copy link
Contributor

luoyuxia commented Apr 9, 2023

@clownxc Thanks for contribution. I'll have a look when i'm free

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants