-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[FLINK-38201] SinkUpsertMaterializer should not be inserted for retract sinks #26879
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
…erted for retract sinks
SinkTestStep.newBuilder("sink_t") | ||
.addSchema( | ||
"name STRING PRIMARY KEY NOT ENFORCED", "score BIGINT") | ||
.addOption("sink-changelog-mode-enforced", "I,UB,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.
I'd probably just have added a plan test to check that SUM is not added anymore. Do we usually prefer semantic tests over to plan tests or is it just a matter of preference?
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.
The PR looks great!
val sinkIsRetract = sinkChangelogMode.contains(RowKind.UPDATE_BEFORE) | ||
|
||
tableConfig.get(ExecutionConfigOptions.TABLE_EXEC_SINK_UPSERT_MATERIALIZE) match { | ||
case UpsertMaterialize.FORCE => primaryKeys.nonEmpty && !sinkIsRetract |
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.
Regarding the two changes
- Auto mode: makes sense we don't add SUM if the sinkIsRetract
- Force: Do we know where
UpsertMaterialize.FORCE
is used? Is it safe to "not respect" the force here?
is it expected that plans for some queries in delta join changed? |
@xuyangzhong what do you think about this change? Is acceptable to simply update the affected test or do we need changes in |
Regarding this change for delta join, I've thought about it, and it is necessary for the DuplicateChangesInferRule to return false when dealing with retract sinks (in Line 169 in cae5fb4
This issue stands on its own, so I can go ahead and create a separate jira to resolve it if you prefer. It's entirely your decision. In summary, here are the situations regarding the failed cases below:
|
Thanks for the quick reply @xuyangzhong. I tried to apply your suggestion to
A lot of test will behave differently with this change. I guess also because |
Sure, @twalthr let's temporarily disable the test |
What is the purpose of the change
Fixes retract sinks by not adding an
SinkUpsertMaterializer
. Since Flink's primary keys are declared as NOT ENFORCED, it is the users responsibility to ensure uniqueness. Retract streams are directly passed through without modification.Brief change log
FlinkChangelogModeInferenceProgram
Verifying this change
This change added tests and can be verified as follows:
SinkSemanticTests
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: noDocumentation