[fluss-client] Support Complex Data Types on the Java API (NestedRow/ROW)#2900
Conversation
757d361 to
86551fa
Compare
…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
86551fa to
12ead45
Compare
|
@XuQianJin-Stars Thanks for the contribution! The feature direction is correct, and the read path implementation is clean. A couple of things to address before this is ready to merge.
In The symmetric read path in Silent type-unsafe round-trip for The The field's declared generic type ( End-to-end tests belong in Rather than introducing a new Let me know your thoughts |
Thanks for the detailed review! All three points make sense to me:
|
1. Pre-compile PojoToRowConverter in write path for ROW elements - PojoArrayToFlussArray: cache converter for ARRAY<ROW> elements - PojoMapToFlussMap: cache converter for ROW-typed map keys/values - Avoids re-creating converter per element (reflection + field scan) 2. Fix type-unsafe round-trip for Map<K, POJO> with ROW value type - Add genericType field to PojoType.Property to preserve generic info - FlussMapToPojoMap now accepts keyClass/valueClass parameters - RowToPojoConverter extracts ParameterizedType args for MAP fields - Map<String, AddressPojo> now correctly round-trips as AddressPojo 3. Migrate tests to proper locations - Move nested ROW POJOs to ConvertersTestFixtures - Move write tests to PojoToRowConverterTest - Move round-trip tests to RowToPojoConverterTest - Delete standalone NestedRowConverterTest
Purpose
Linked issue: close #2805
This pull request extends the Java Typed API to support the
ROWdata type (nested POJO) in POJO ↔ InternalRow conversion, completing the complex type coverage alongside the already supportedARRAYandMAPtypes.Brief change log
ConverterCommons.java: AddedROWtype validation invalidateCompatibility()— 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: Addedcase ROW:increateFieldConverter()— recursively creates a nestedPojoToRowConverterto convert a nested POJO field into aGenericRow.RowToPojoConverter.java: Addedcase ROW:increateRowReader()— recursively creates a nestedRowToPojoConverterto convert anInternalRowback into a nested POJO.PojoTypeToFlussTypeConverter.java: Addedcase ROW:inconvertElementValue()— supports serializing nested ROW elements withinARRAYandMAPtypes.FlussArrayToPojoArray.java: Addedcase ROW:inbuildElementConverter()— supports deserializing ROW elements within arrays. Falls back to returning rawInternalRowwhen the target POJO type isObject.class(due to Java type erasure in MAP values).java-client.md: AddedROW → Nested POJOentry 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 forMAP<K, ROW>.Tests
NestedRowConverterTest#testSimpleNestedRowRoundTrip— basic POJO with a nested ROW field, roundtrip serialization/deserializationNestedRowConverterTest#testNullNestedRow— null nested POJO is correctly handledNestedRowConverterTest#testDeeplyNestedRowRoundTrip— two-level deep nesting (POJO → ROW → ROW)NestedRowConverterTest#testNestedRowWithArrayFieldRoundTrip— nested POJO containing anARRAY<INT>fieldNestedRowConverterTest#testNestedRowWithMapFieldRoundTrip— nested POJO containing aMAP<STRING, INT>fieldNestedRowConverterTest#testArrayOfNestedRowRoundTrip— top-levelARRAY<ROW<...>>mapped to a POJO arrayNestedRowConverterTest#testMapWithRowValuesRoundTrip—MAP<STRING, ROW<...>>with type erasure fallback (values deserialized asInternalRow)NestedRowConverterTest#testRowFieldWithIncompatibleType— validates that an array type field is rejected when mapped to ROWNestedRowConverterTest#testRowFieldWithMapType— validates that a Map type field is rejected when mapped to ROWAPI and Format
No. This change only adds internal converter logic for the existing
ROWdata type. No public API or storage format changes.Documentation
Updated
website/docs/apis/java-client.md:ROW | Nested POJOto the type mapping tableARRAY<ROW>, andMAP<String, ROW>usage