[coordinator] Refactor SchemaUpdate to delegate schema changes to Schema.Builder #2416
+39
−54
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.
Purpose
Linked issue: close #2344
The purpose of this change is to refactor the SchemaUpdate class to delegate all schema membership management (columns, primary keys, and auto-increment fields) directly to Schema.Builder. Currently, SchemaUpdate manually maintains these members, which is error-prone and can lead to broken schemas during evolution.
Brief change log
Refactored SchemaUpdate: Removed local lists for columns, primary keys, and auto-increment fields.
Builder Delegation: Modified SchemaUpdate to directly maintain a Schema.Builder instance, ensuring a single source of truth for schema building and validation logic.
Enhanced Schema.Builder: Updated Schema.Builder#fromSchema to correctly adopt all members from an existing schema, including column IDs and metadata.
Added Helper API: Added Schema.Builder#getColumn(String columnName) to allow checking for existing columns within the builder's state.
Tests
Verified the fix by running TableSchemaTest and SchemaUpdateTest to ensure the delegation logic handles schema evolution correctly without IllegalStateException.
Performed a full test suite execution for the fluss-common module: mvn test -pl fluss-common.
Results: 1,491 tests run, 0 failures.
API and Format
This change adds a public helper method getColumn(String columnName) to the Schema.Builder API.
It does not affect the storage format.
Documentation
This change does not introduce a new feature; it is a refactoring of existing internal logic.