[FLINK-40528][table] Make codegen tolerant to partial deletes - #29060
Open
snuyanzin wants to merge 2 commits into
Open
[FLINK-40528][table] Make codegen tolerant to partial deletes#29060snuyanzin wants to merge 2 commits into
snuyanzin wants to merge 2 commits into
Conversation
snuyanzin
force-pushed
the
flink40528
branch
from
September 1, 2026 06:33
d4a27c9 to
9b5d43c
Compare
snuyanzin
force-pushed
the
flink40528
branch
from
September 1, 2026 08:49
9b5d43c to
589bd9f
Compare
gustavodemorais
left a comment
Contributor
There was a problem hiding this comment.
Thanks for looking into this and the fix, Sergey!
I like the fix. As I expected though, we still have more gaps:
generatePrimitiveArrayUpdateCode(ARRAY[...]/MAP[...]literals) still gates onelementType.isNullableonly:
SELECT id, ROW(id, ARRAY[v, 99]) FROM source_t
-D[1, +I[1, [-1, 99]]] <- should be null, writes -1
generateMap hits the same function for fixed-length primitive keys/values.
JsonGenerateUtils.createNullableNodeTermhas the same gate, also untouched
SELECT id, JSON_OBJECT('r' VALUE ROW(v)) FROM source_t
-D[1, {"r":{"EXPR$0":0}}] <- should be null, writes 0
- And separately, we also need to fix the ConstraintEnforcer. FLINK-40477 (
NOT_NULL_ERROR_DELETE_BY_KEY- bare scalar passthrough, no composite at all) is a different bug in a different module (ConstraintEnforcerExecutor). Simple projections without Row fail still because we have partial deletes.
SELECT id, v FROM source_t -- sink column v INT NOT NULL
EnforcerException: Column 'v' is NOT NULL, however, a null value is being written into it.
In general, the partial deletes optimization is broken. I think these three above are doable so I'm +1 into fix forward: we fix them instead of forcing ChangelogNormalize back into the pipelines. I think 1. fits into this PR and 2. maybe, up to you. For 3, I think it makes sense to do it in another PR.
| if (element.literal) { | ||
| "" | ||
| } else if (tpe.isNullable) { | ||
| } else if (tpe.isNullable || element.nullTerm != NEVER_NULL) { |
Contributor
There was a problem hiding this comment.
Can we extract this as a small helper to slightly improve readability?
/** True only when codegen proved this statically; a dynamic nullTerm may still be null at runtime. */
def isProvenNonNull: Boolean = nullTerm == NEVER_NULL
...
} else if (tpe.isNullable || !element.isProvenNonNull) {
gustavodemorais
requested changes
Sep 1, 2026
snuyanzin
force-pushed
the
flink40528
branch
from
September 1, 2026 12:26
bdfa85d to
749d1c4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
The PR makes codegen tolerant to partial deletes
Brief change log
codegen
Verifying this change
tests
Does this pull request potentially affect one of the following parts:
@Public(Evolving): (no)Documentation
Was generative AI tooling used to co-author this PR?
Generated-by: [Tool Name and Version]