Skip to content

[server] Support adding nested fields to ROW columns - #4905

Draft
raoluSmile wants to merge 1 commit into
apache:mainfrom
raoluSmile:feature_alterSchema_NestedRow
Draft

raoluSmile wants to merge 1 commit into
apache:mainfrom
raoluSmile:feature_alterSchema_NestedRow

Conversation

@raoluSmile

Copy link
Copy Markdown

Purpose

Linked issue: #4889

This PR introduces the API, RPC and coordinator-side metadata support for adding nested fields to ROW columns. Runtime read/write adaptation and recovery integration will follow in separate PRs.

This PR implements the API and coordinator-side metadata changes for adding nullable fields to existing ROW columns, as part of the nested schema evolution work tracked by the linked issue.

For example, at the schema metadata level, a column defined as profile ROW<name STRING> can be extended to profile ROW<name STRING, age INT>. Fields can also be appended to ROW types nested within other ROW types.

This is a partial implementation. Runtime adaptation for existing data, read/write and recovery integration, Flink SQL support, and field additions inside ARRAY are follow-up work.

The PR is intended for early review and design discussion alongside the planned FIP. It does not provide complete end-to-end nested schema evolution on its own.

Brief change log

  • Introduce ColumnPath to represent paths to nested fields and TableChange.addNestedField(...) to describe a nested field addition.
  • Extend AlterTableRequest with nested field additions and implement the corresponding client/server RPC conversions.
  • Implement recursive schema updates for appending nullable fields to existing ROW types.
  • Preserve existing field IDs and schema metadata, allocate IDs for newly added fields and their nested children, and update highestFieldId.
  • Validate parent paths, parent types, duplicate field names and nullability. Reject changes beneath primary key, bucket key or partition key columns, and changes to datalake-enabled tables.
  • Restrict schema updates to ROW field paths. ARRAY element and MAP value path segments are represented in the API/RPC but are rejected by the schema updater in this PR.

Tests

Added or extended coverage in:

  • ColumnPathTest: path construction, parsing, validation, immutability, equality, serialization and nested field change construction.
  • ClientRpcMessageUtilsTest: nested field request serialization and deserialization alongside existing alter-table operations.
  • ServerRpcMessageUtilsTest: nested field request conversion, optional comments, path segments and malformed request validation.
  • SchemaUpdateNestedFieldTest: nested ROW field additions, field ID allocation, metadata preservation, invalid changes and schema registration through MetadataManager.

End-to-end read/write and recovery coverage will accompany the runtime integration work.

API and Format

  • Adds the public ColumnPath type and the TableChange.addNestedField(...) API.
  • Adds PbColumnPathSegment, PbAddNestedField and the add_nested_fields field to the alter-table RPC request.
  • Uses the existing schema metadata representation for updated ROW types. This PR does not change the Log/KV record binary layout.

Mixed-version behavior and end-to-end data compatibility are not established by the tests in this PR.

Documentation

Adds Javadocs for the new API.

User-facing documentation and SQL examples will be added with the end-to-end feature. The proposed API, semantics and implementation plan will be discussed in the FIP.

@raoluSmile raoluSmile changed the title [server] Support adding nested fields to ROW columns during schema evolution [server] Support adding nested fields to ROW columns Oct 27, 2026
@raoluSmile
raoluSmile marked this pull request as ready for review October 27, 2026 03:10
@raoluSmile
raoluSmile marked this pull request as draft October 27, 2026 03:11
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.

1 participant