Skip to content

[fluss-client] Support Complex Data Types on the Java API (NestedRow/ROW)#2900

Open
XuQianJin-Stars wants to merge 1 commit intoapache:mainfrom
XuQianJin-Stars:feature/support-nestedrow-typed-api
Open

[fluss-client] Support Complex Data Types on the Java API (NestedRow/ROW)#2900
XuQianJin-Stars wants to merge 1 commit intoapache:mainfrom
XuQianJin-Stars:feature/support-nestedrow-typed-api

Conversation

@XuQianJin-Stars
Copy link
Contributor

Purpose

Linked issue: close #2805

This pull request extends the Java Typed API to support the ROW data type (nested POJO) in POJO ↔ InternalRow conversion, completing the complex type coverage alongside the already supported ARRAY and MAP types.

Brief change log

  • ConverterCommons.java: Added ROW type validation in validateCompatibility() — ensures the POJO field for a ROW type is not a primitive, array, Collection, or Map. Detailed field-level validation is deferred to the nested converter.
  • PojoToRowConverter.java: Added case ROW: in createFieldConverter() — recursively creates a nested PojoToRowConverter to convert a nested POJO field into a GenericRow.
  • RowToPojoConverter.java: Added case ROW: in createRowReader() — recursively creates a nested RowToPojoConverter to convert an InternalRow back into a nested POJO.
  • PojoTypeToFlussTypeConverter.java: Added case ROW: in convertElementValue() — supports serializing nested ROW elements within ARRAY and MAP types.
  • FlussArrayToPojoArray.java: Added case ROW: in buildElementConverter() — supports deserializing ROW elements within arrays. Falls back to returning raw InternalRow when the target POJO type is Object.class (due to Java type erasure in MAP values).
  • java-client.md: Added ROW → Nested POJO entry to the type mapping table and a new "Nested POJOs (ROW Type)" documentation section with usage examples and a note about the Java type erasure limitation for MAP<K, ROW>.

Tests

  • NestedRowConverterTest#testSimpleNestedRowRoundTrip — basic POJO with a nested ROW field, roundtrip serialization/deserialization
  • NestedRowConverterTest#testNullNestedRow — null nested POJO is correctly handled
  • NestedRowConverterTest#testDeeplyNestedRowRoundTrip — two-level deep nesting (POJO → ROW → ROW)
  • NestedRowConverterTest#testNestedRowWithArrayFieldRoundTrip — nested POJO containing an ARRAY<INT> field
  • NestedRowConverterTest#testNestedRowWithMapFieldRoundTrip — nested POJO containing a MAP<STRING, INT> field
  • NestedRowConverterTest#testArrayOfNestedRowRoundTrip — top-level ARRAY<ROW<...>> mapped to a POJO array
  • NestedRowConverterTest#testMapWithRowValuesRoundTripMAP<STRING, ROW<...>> with type erasure fallback (values deserialized as InternalRow)
  • NestedRowConverterTest#testRowFieldWithIncompatibleType — validates that an array type field is rejected when mapped to ROW
  • NestedRowConverterTest#testRowFieldWithMapType — validates that a Map type field is rejected when mapped to ROW

API and Format

No. This change only adds internal converter logic for the existing ROW data type. No public API or storage format changes.

Documentation

Updated website/docs/apis/java-client.md:

  • Added ROW | Nested POJO to the type mapping table
  • Added a new "Nested POJOs (ROW Type)" section with code examples showing direct ROW fields, ARRAY<ROW>, and MAP<String, ROW> usage
  • Added a note about Java type erasure limitation for MAP values

@XuQianJin-Stars
Copy link
Contributor Author

@polyzos Hi, i already updated the pr. Please help review when you got some time.

@XuQianJin-Stars XuQianJin-Stars force-pushed the feature/support-nestedrow-typed-api branch from 757d361 to 86551fa Compare March 18, 2026 12:15
…edRow/ROW)

- Add ROW type support in PojoToRowConverter (POJO -> GenericRow)
- Add ROW type support in RowToPojoConverter (InternalRow -> POJO)
- Add ROW type validation in ConverterCommons
- Add ROW element support in PojoTypeToFlussTypeConverter (for Array/Map)
- Add ROW element support in FlussArrayToPojoArray (for Array<ROW>)
- Add comprehensive tests for nested ROW, deeply nested ROW, ROW with
  Array/Map fields, Array<ROW>, Map<K, ROW>, null handling, and validation
- Update java-client.md documentation with ROW type mapping and usage examples
@XuQianJin-Stars XuQianJin-Stars force-pushed the feature/support-nestedrow-typed-api branch from 86551fa to 12ead45 Compare March 18, 2026 12:17
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.

Support Complex Data Types on the Java Typed API

1 participant