Repository navigation
[Java] Mark the casters of TSDataType transient so that Flink accepts a TSDataType - #1065
Merged
Merged
Conversation
Since apache#872, every TSDataType constant holds a SingleValueCaster and an ArrayCaster, initialised with lambdas that are not serializable. Java serializes an enum constant only by its name, but Flink's ClosureCleaner checks every non-static, non-transient field of the objects reachable from a function, including the fields of enum constants. A Flink job whose function or input format reaches a TSDataType through its fields is therefore rejected with "TSDataType$$Lambda... is not serializable". Mark both fields transient. Nothing reads them after serialization, since deserializing an enum constant returns the existing constant.
jt2594838
approved these changes
Nov 5, 2026
Contributor
|
LGTM |
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.
Description
Since #872, every
TSDataTypeconstant holds aSingleValueCasterand anArrayCaster, set to lambdas that are not serializable (TSDataType.java:129-:130ondevelop). Java serializes an enum constant only by its name, so Java serialization is not affected. Flink'sClosureCleaner, however, serializes every non-static, non-transient field of the objects that a function holds, including the fields of enum constants, and rejects the function when one of them fails.I ran into this while raising iotdb-extras to TsFile 2.5.0.
RowTsFileInputFormatIntegrationTest.testStreamExecutionof its Flink TsFile connector (Flink 1.17.1) passes with TsFile 2.4.0 and fails with 2.5.0:The input format reaches a
TSDataTypethroughTsFileInputFormat.config→TSFileConfig.timeSeriesDataType, andClosureCleanerrecurses into every field that is neither static nor transient (needsRecursionin Flink 1.17). Until a release has this change, a job on 2.5.0 can avoid it withenv.getConfig().setClosureCleanerLevel(ExecutionConfig.ClosureCleanerLevel.TOP_LEVEL).Change
Both fields are now
transient. Nothing reads them after deserialization, because deserializing an enum constant returns the existing constant.Verification
TSDataTypeSerializationTestinjava/common:NotSerializableException: org.apache.tsfile.enums.TSDataType$$Lambda...;java/commonpass, and so doTypeCastTestandTsPrimitiveTypeTestinjava/tsfile.spotless:checkpasses.2.5.0-tsfix. With it, all 8 tests of the iotdb-extrasflink-tsfile-connectorpass, includingtestStreamExecution.