[FLINK-40444][table-common] Preserve attribute order in OBJECT_UPDATE - #28994
Open
SEPURI-SAI-KRISHNA wants to merge 1 commit into
Open
[FLINK-40444][table-common] Preserve attribute order in OBJECT_UPDATE#28994SEPURI-SAI-KRISHNA wants to merge 1 commit into
SEPURI-SAI-KRISHNA wants to merge 1 commit into
Conversation
ObjectUpdateTypeStrategy collected the result attributes into a HashMap and iterated its entry set, so the inferred structured type followed hash order instead of the declaration order of the input type. The runtime writes updated values at the declared positions, so the inferred type and the produced row disagreed whenever the attribute names did not happen to hash in declaration order. Depending on the attribute types this surfaced either as a ClassCastException or as values silently appearing under the wrong attributes. Generated-by: Claude Code (Opus 5)
Collaborator
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
OBJECT_UPDATEinferred its result type by collecting the attributes of the inputstructured type into a
HashMapand iterating the entry set, so the resulting typefollowed hash order rather than the declaration order of the input type. The runtime
writes updated values at the declared positions, so the inferred type and the
produced row disagreed whenever the attribute names did not happen to hash in
declaration order.
Depending on the attribute types this surfaced either as a
ClassCastExceptionatruntime, or as a query that succeeded while silently returning values under the wrong
attribute names. For example, before this change:
while
OBJECT_OFon its own correctly returns the attributes in declaration order(
b,a). This affects release-2.2 and release-2.3.Brief change log
ObjectUpdateTypeStrategycollects the result attributes into aLinkedHashMap, so the inferred attribute order matches the declaration order of the input typeTypeStrategiesTestBasesets aDataTypeFactoryMockon the call context mock, mirroringInputTypeStrategiesTestBase; this is required becauseObjectUpdateTypeStrategyresolves the structured class through the data type factory's class loaderVerifying this change
This change added tests and can be verified as follows:
ObjectUpdateTypeStrategyTestwith three cases pinning the inferred attribute order, using attribute names whose hash order differs from their declaration orderStructuredFunctionsITCasewith an end-to-end case asserting both the result values and the resulting structured typeClassCastException: BinaryStringData cannot be cast to java.lang.Integer, and passes with itDoes this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5)