Skip to content

[kafka] Unify schema type validation for Kafka table mappings - #4766

Open
wuchong wants to merge 1 commit into
apache:mainfrom
wuchong:kafka-schema-type-validation
Open

wuchong wants to merge 1 commit into
apache:mainfrom
wuchong:kafka-schema-type-validation

Conversation

@wuchong

@wuchong wuchong commented Oct 20, 2026

Copy link
Copy Markdown
Member

Purpose

Closes #4765. Part of #4185.

Kafka table schema validation currently mixes per-column type checks with a dedicated _kafka_metadata comparison. Consolidate these checks around expected types while preserving the existing mapping contract, and include the actual type in validation errors.

Brief change log

  • Add DataTypeChecks.equalsIgnoreFieldDescriptionsAndIds, recursively comparing ROW, ARRAY, and MAP types while preserving field names, field order, nullability, and type parameters.
  • Reuse the comparison for Kafka system columns and binary/string _kafka_value validation.
  • Cover field IDs/comments, mismatched type classes, field renaming/reordering, and nullability in unit tests; extend coordinator DDL tests for metadata with comments and invalid metadata on table creation or Kafka enablement.

Tests

  • Passed the Kafka reactor verification and style/license checks:
    ./mvnw -B verify spotless:check -pl fluss-kafka -am \
      '-Dtest=Kafka*Test,Kafka*ITCase,ApiVersionsHandlerTest,DataTypeChecksTest' \
      -Dsurefire.failIfNoSpecifiedTests=false
    All 82 distinct Kafka test cases passed, including all 19 KafkaTableMappingITCase cases. DataTypeChecksTest (17) and KafkaTableSchemaTest (36) also passed. Counts do not add together repeated Surefire lifecycle executions.
  • The earlier full-reactor run completed all 2,079 fluss-common test cases (1 skipped, no failures/errors) and all 157 RPC cases (2 skipped, no failures/errors).
  • git diff --check, Spotless, Checkstyle, and RAT passed for the validated reactor.
  • Full-reactor ./mvnw -B verify spotless:check was attempted but did not complete: RemoteLogManagerTest remained in ReplicaTestBase.setup, retrying ZooKeeperClient.registerTable, for more than eight minutes. Two thread dumps confirmed the same setup path before the run was terminated. The remaining full-reactor tests are not claimed as passing.

API and Format

Adds a type-comparison utility. No wire or storage format changes; the Kafka DDL schema contract is preserved. Type-validation error messages now include the actual type.

Documentation

No user documentation changes are needed for this validation refactor.

Generative AI disclosure

Codex was used to review, validate, and prepare this pull request from existing local changes.

Compare types recursively while ignoring ROW field descriptions and IDs,
preserving field names, order, nullability, and type parameters. Reuse the
comparison for Kafka column contracts and cover metadata validation
through unit tests and coordinator DDL integration tests.

Fixes apache#4765

Co-Authored-By: Codex <noreply@openai.com>
AI-Model: gpt-6

AI-Contributed/Feature: 0/146
AI-Contributed/UT: 0/290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[kafka] Unify schema type validation for Kafka table mappings

1 participant