Skip to content

Conversation

@Prajwal-banakar
Copy link
Contributor

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.

@Prajwal-banakar Prajwal-banakar force-pushed the schemaupdate-delegation branch from 5da4435 to f10a940 Compare January 20, 2026 12:48
@Prajwal-banakar Prajwal-banakar changed the title [common] Refactor SchemaUpdate to delegate schema changes to Schema.Builder [coordinator] Refactor SchemaUpdate to delegate schema changes to Schema.Builder Jan 20, 2026
Copy link
Member

@wuchong wuchong left a comment

Choose a reason for hiding this comment

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

@Prajwal-banakar thanks for the contribution. The new code looks much clear now. I only left a minor comment.

@loserwang1024 could you have another look?

Comment on lines 288 to 291
// 1. Clear current builder state
this.columns.clear();
this.autoIncrementColumnNames.clear();
this.primaryKey = null;
Copy link
Member

Choose a reason for hiding this comment

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

I think it's better make sure the fromSchema is the first API to be called on the builder, rather than silently dropping previous columns. Otherwise, it's hard to debug the problem. You can validate all the members should be empty.

/** Schema update. */
public class SchemaUpdate {

/** Apply schema changes to the given table info and return the updated schema. */
Copy link
Member

Choose a reason for hiding this comment

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

Keep the original javadoc?

@Prajwal-banakar Prajwal-banakar force-pushed the schemaupdate-delegation branch from f10a940 to 08590d8 Compare January 21, 2026 17:19
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.

Use Schema.Builder#fromSchema in SchemaUpdate

2 participants