fix: handle empty struct in CompareSchemasVisitor.struct() - #17683
Open
waterWang wants to merge 3 commits into
Open
fix: handle empty struct in CompareSchemasVisitor.struct()#17683waterWang wants to merge 3 commits into
waterWang wants to merge 3 commits into
Conversation
ebyhr
reviewed
Aug 16, 2026
ebyhr
left a comment
Member
There was a problem hiding this comment.
Can we add a regression test, or do you think it's overkill?
uros-b
reviewed
Aug 17, 2026
uros-b
left a comment
Member
There was a problem hiding this comment.
+1 with @ebyhr for adding regression testing. Issue #17650 supplies a ready repro, right @waterWang?
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.
Fixes #17650
Problem
CompareSchemasVisitor.struct()computes its result as:For a struct with zero fields, the
reduceis empty, soorElse(SCHEMA_UPDATE_NEEDED)always fires. Consequently any schema containing an empty struct (e.g. derived from an Avro union whose branch is a zero-field marker record) can never compareSAMEwith any table schema — including a table created from that exact schema.In the Dynamic Sink this is fatal:
TableUpdater.findOrCreateSchemaseesSCHEMA_UPDATE_NEEDED, appliesEvolveSchemaVisitor(a no-op here), commits, re-compares — stillSCHEMA_UPDATE_NEEDED— andTableMetadataCache.schema()caches and returnsNOT_FOUND, whoseresolvedTableSchema()is null.Fix
Change
orElse(Result.SCHEMA_UPDATE_NEEDED)toorElse(Result.SAME)— when both structs have zero fields, they are semantically identical.Changes
flink/v1.20/flink/src/main/java/.../CompareSchemasVisitor.javaflink/v2.0/flink/src/main/java/.../CompareSchemasVisitor.javaflink/v2.1/flink/src/main/java/.../CompareSchemasVisitor.javaAll three versions had the same bug (identical content).