-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-38417] Ensure attribute ordering when managing join attributes in JoinKeyExtractor #27033
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
base: master
Are you sure you want to change the base?
Conversation
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 this big refactoring and adding all these Javadocs with examples. Improves the readability significantly. I had just minor comments.
* <p>Example used throughout the comments: t1.id1 = t2.user_id2 and t3.user_id3 = t2.user_id2. All | ||
* three attributes (t1.id1, t2.user_id2, t3.user_id3) represent the same conceptual key. | ||
* | ||
* <p>The {@code joinAttributeMap} for this example would be structured as follows: |
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 this example. Way easier to understand!
userIdFieldName, pkFieldName, String.format("details_%d", inputIndex) | ||
}); | ||
} else if (inputIndex | ||
== 3) { // Shipments: user_id (VARCHAR), pk (VARCHAR), details (BIGINT) |
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.
== 3) { // Shipments: user_id (VARCHAR), pk (VARCHAR), details (BIGINT) | |
== 3) { // Shipments: user_id (CHAR NOT NULL), pk (VARCHAR), details (BIGINT) |
String userIdFieldName = String.format("user_id_%d", inputIndex); | ||
String pkFieldName = String.format("pk_%d", inputIndex); // Generic PK name | ||
|
||
if (inputIndex == 0) { // Users: user_id (VARCHAR), pk (VARCHAR), details (BIGINT) |
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.
if (inputIndex == 0) { // Users: user_id (VARCHAR), pk (VARCHAR), details (BIGINT) | |
if (inputIndex == 0) { // Users: user_id (CHAR NOT NULL), pk (VARCHAR), details (BIGINT) |
+ "k3 BOOLEAN," | ||
+ "k2 INT," | ||
+ "k4 STRING") | ||
.addOption("changelog-mode", "I") |
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.
Use the new addMode(ChangelogMode.insertOnly())
"k2 INT", | ||
"k3 BOOLEAN", | ||
"k4 STRING") | ||
.addOption("changelog-mode", "I,UA,UB,D") |
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.
Use the new addMode(ChangelogMode.all())
.addSchema( | ||
"`record_id` STRING PRIMARY KEY NOT ENFORCED", | ||
"`user_id` INT") | ||
.addOption("changelog-mode", "I,UA,D") |
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.
Use the new addMode(ChangelogMode.upsert())
Thanks for the review, @twalthr! I've addressed the comments and replaced all changelogs with the new |
What is the purpose of the change
The MultiJoin has a JoinKeyExtractor helper that derives keys from AttributeRef mappings in the joinAttributeMap. It describes how attributes from different inputs are equated via equi-join * conditions.
The methods present in the JoinKeyExtractor should always return rows for the join conditions and commonJoinKey in the same order so we have stable a joinKey for state access and key selector for routing. This adds a fix to make sure the order is maintained.
To make the whole class easier to read, I've also refactored it, added comments and examples.
Brief change log
Verifying this change
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation