Skip to content

[FLINK-40597][core] Fix input type validation for Types.UUID - #29133

Merged
twalthr merged 2 commits into
apache:masterfrom
dylanhz:codex/fix-uuid-type-validation
Sep 14, 2026
Merged

[FLINK-40597][core] Fix input type validation for Types.UUID#29133
twalthr merged 2 commits into
apache:masterfrom
dylanhz:codex/fix-uuid-type-validation

Conversation

@dylanhz

@dylanhz dylanhz commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Fix FLINK-40597: a DataStream created with explicit Types.UUID can fail input type validation for a non-lambda MapFunction<UUID, String> with Input mismatch: Basic type expected.

Brief change log

  • Recognize java.util.UUID when validating explicitly specified basic type information.
  • Leave UUID extraction without explicit type information unchanged (GenericTypeInfo<UUID> with Kryo by default). Automatic extraction as Types.UUID is tracked separately in FLINK-40546.

Verifying this change

  • Added a fromData(Types.UUID, ...).map(...) regression test and a check that fromData(...) still infers GenericTypeInfo<UUID>.
  • Confirmed the regression test fails without the fix and passes with it.
  • DataStreamTest and TypeExtractorTest: 102 tests passed after rebasing onto master.
  • Full ./mvnw clean verify was attempted. After resolving a local Python executable issue and resuming, verification stopped at flink-s3-fs-base: SeaweedFsTestContainerTest requires Docker, which is not installed locally. Subsequent modules have not been verified.

Does this pull request potentially affect one of the following parts:

  • Dependencies: no
  • Public API: yes, fixes validation in the existing @Public TypeExtractor; no API signatures change
  • Serializers: no
  • Runtime per-record code paths: no
  • Deployment or recovery: no
  • S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Codex 0.147.0 (model: gpt-6)

@dylanhz
dylanhz marked this pull request as ready for review September 8, 2026 16:05
@flinkbot

flinkbot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@dylanhz
dylanhz force-pushed the codex/fix-uuid-type-validation branch 2 times, most recently from 3936022 to e0c0526 Compare September 9, 2026 09:03
Generated-by: Codex 0.147.0 (model: gpt-6)
@dylanhz
dylanhz force-pushed the codex/fix-uuid-type-validation branch from e0c0526 to ccfe431 Compare September 9, 2026 11:38

@raminqaf raminqaf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this @dylanhz! I have added some comments

Comment on lines +844 to +850
final MapFunction<UUID, String> mapper =
new MapFunction<UUID, String>() {
@Override
public String map(UUID value) {
return value.toString();
}
};

@raminqaf raminqaf Sep 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the MapFunction return the UUID type as byte[] or Byte? Let's add a test like this

    @Test
    void testMapToBytesWithExplicitUuidType() {
        final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        // A lambda would bypass the input validation exercised by this test.
        final MapFunction<UUID, byte[]> byteMapper = value -> {
            ByteBuffer buffer = ByteBuffer.wrap(new byte[16]);
            buffer.putLong(value.getMostSignificantBits());
            buffer.putLong(value.getLeastSignificantBits());
            return buffer.array();
        };

        final DataStream<byte[]> stream = env.fromData(Types.UUID, new UUID(0L, 0L)).map(byteMapper);

        assertThat(stream.getType()).isEqualTo(PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO);
    }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even having a test for Mapping String -> UUID

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UUID → byte[] seems to exercise the same input validation as UUID → String, while String → UUID covers output extraction. Is there a specific scenario you’d like these tests to cover?

Comment on lines +1507 to +1510
final TypeInformation<?> actual =
type == UUID.class
? BasicTypeInfo.UUID_TYPE_INFO
: BasicTypeInfo.getInfoFor((Class<?>) type);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test in TypeExtractorTest?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Moved both tests to TypeExtractorTest.

@github-actions github-actions Bot added the community-reviewed PR has been reviewed by the community. label Sep 11, 2026
@dylanhz
dylanhz force-pushed the codex/fix-uuid-type-validation branch from b2d9415 to 792f7a8 Compare September 14, 2026 07:35

@twalthr twalthr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you @dylanhz

@twalthr
twalthr merged commit ac9d2aa into apache:master Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants