Skip to content

Conversation

gustavodemorais
Copy link
Contributor

What is the purpose of the change

It'd be useful to have some changes to the explain to make debugging and looking at the job graph easier:

  • Add inputUniqueKeys
  • Add commonJoinKey
  • Add names instead of indices for joinFilter and joinConditions
  • Remove joinAttributeMap since it's not easily readable and really long

Brief change log

  • Refactor explain in physical node
  • Update tests accordingly

Verifying this change

Plan and restore tests updated (this is ok because the operator is in an experimental state)

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): (no)
  • 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)
  • If yes, how is the feature documented? (not applicable)

@flinkbot
Copy link
Collaborator

flinkbot commented Aug 19, 2025

CI report:

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

@davidradl
Copy link
Contributor

@gustavodemorais looks like a planner test is failing in the are you have changed.

@gustavodemorais
Copy link
Contributor Author

I've rebased it twice already so I'll rebase it after getting a review

postJoinFilter != null)
.item("select", String.join(",", getRowType().getFieldNames()))
.item("rowType", getRowType())
.item("outputRowType", getRowType())
Copy link
Contributor

Choose a reason for hiding this comment

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

we should make sure that this is insync with other explains, I would suggest to keep it rowType

} ],
"outputType" : "ROW<`user_id` VARCHAR(2147483647), `name` VARCHAR(2147483647), `user_id0` VARCHAR(2147483647), `order_id` VARCHAR(2147483647), `user_id1` VARCHAR(2147483647), `payment_id` VARCHAR(2147483647)>",
"description" : "MultiJoin(joinFilter=[true], joinTypes=[[INNER, LEFT, LEFT]], joinConditions=[[true, =($0, $2), =($0, $4)]], joinAttributeMap=[{1=[LeftInputId:0;LeftFieldIndex:0;RightInputId:1;RightFieldIndex:0;], 2=[LeftInputId:0;LeftFieldIndex:0;RightInputId:2;RightFieldIndex:0;]}], select=[user_id,name,user_id0,order_id,user_id1,payment_id], rowType=[RecordType(VARCHAR(2147483647) user_id, VARCHAR(2147483647) name, VARCHAR(2147483647) user_id0, VARCHAR(2147483647) order_id, VARCHAR(2147483647) user_id1, VARCHAR(2147483647) payment_id)])"
"description" : "MultiJoin(commonJoinKey=[user_id], joinTypes=[INNER, LEFT, LEFT], inputUniqueKeys=[noUniqueKey, noUniqueKey, noUniqueKey], joinConditions=[true, (user_id = user_id0), (user_id = user_id1)], joinFilter=[true], select=[user_id,name,user_id0,order_id,user_id1,payment_id], outputRowType=[RecordType(VARCHAR(2147483647) user_id, VARCHAR(2147483647) name, VARCHAR(2147483647) user_id0, VARCHAR(2147483647) order_id, VARCHAR(2147483647) user_id1, VARCHAR(2147483647) payment_id)])"
Copy link
Contributor

Choose a reason for hiding this comment

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

remove joinFilter=[true]

.collect(Collectors.joining(", ")))
.item("inputUniqueKeys", formatInputUniqueKeysWithFieldNames())
.item("joinConditions", formatJoinConditionsWithFieldNames(pw))
.itemIf(
Copy link
Contributor

Choose a reason for hiding this comment

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

remove as it is contained in joinConditions already

@gustavodemorais
Copy link
Contributor Author

gustavodemorais commented Sep 29, 2025

Thanks for the review, @twalthr! I've addressed your comments.

I've also moved the only single plan test that was outside the MultiJoinTest file so that it's simpler to regenerate plans in the future. (The test wasn't changed).

@gustavodemorais
Copy link
Contributor Author

On another note, do you think it makes sense to remove the position 0 from all arrays related to joins? Right now, for N inputs, all arrays in the explain are of length N. However, for N inputs, we have N - 1 joins.

The first position of all arrays in the MultiJoin node related to joins are a special case. Each position in the array is related to the join between inputs i and i - 1. The position 0 has some default values since these are the values related to joining input 0 and "input -1". For example, a regular two way join has arrays with a length of two for the properties

joinTypes=[INNER, INNER],
inputUniqueKeys=[(user_id), (order_id, user_id)] 
joinConditions=[true, =(user_id, user_id0)]

Calcite creates as a default value for pos 0. The same thing with the joinTypes, the first position is always INNER. In general, I think it either makes sense keep the position 0 like above for all attributes so they have the same length or remove for it only for the join-related attributes. What do you think?

@twalthr
Copy link
Contributor

twalthr commented Sep 29, 2025

I agree to simplify the explain here. A binary join should be:

joinTypes=[INNER],
inputUniqueKeys=[(user_id), (order_id, user_id)] 
joinConditions=[=(user_id, user_id0)]

So inputUniqueKeys relates to inputs and thus N input == N values. Others are join related and thus N-1.

@gustavodemorais
Copy link
Contributor Author

gustavodemorais commented Sep 30, 2025

I've updated both joinTypes and joinConditions to skip the first position. It looks cleaner 👍

I've also moved up stateTtlHints to the beginning of the list next to inputUniqueKeys, since it's also related to inputs and is a short and a more relevant information than the lengthy outputType.

I think we have everything now. Can you take a look @twalthr?

Copy link
Contributor

@twalthr twalthr left a comment

Choose a reason for hiding this comment

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

LGTM

@gustavodemorais gustavodemorais force-pushed the FLINK-38211 branch 3 times, most recently from 84242ac to 1182bbc Compare October 1, 2025 14:15
@dawidwys dawidwys merged commit 45c47ba into apache:master Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants