geyanggang opened a new pull request, #10927:
URL: https://github.com/apache/gravitino/pull/10927

   ### What changes were proposed in this pull request?
   
   Use `ExternalType` to preserve Paimon's MULTISET type information through 
Gravitino's type system, instead of converting it to `MapType` which causes a 
schema mismatch error.
   
   Changes:
   - **Paimon catalog backend (`TypeUtils.java`)**: `visit(MultisetType)` now 
returns `ExternalType` with the original SQL string instead of `MapType`. Added 
`EXTERNAL` case in `GravitinoToPaimonTypeVisitor` to restore `MultisetType` 
using `DataTypeJsonParser`.
   - **Flink Connector (`TypeUtils.java`)**: `toGravitinoType` MULTISET case 
now returns `ExternalType`. Added `EXTERNAL` case in `toFlinkType` using 
Flink's `LogicalTypeParser` to restore the original Flink type.
   - **Unit test**: Added `testMultisetTypeConversion` to verify round-trip 
conversion.
   
   ### Why are the changes needed?
   
   When a Paimon table contains a `MULTISET<STRING>` column and is accessed 
through the Gravitino Flink Connector, writing to the table fails with:
   IllegalArgumentException: Flink schema and store schema are not the same 
store schema: field_multiset MULTISET<STRING> Flink schema: field_multiset 
MAP<STRING, INT NOT NULL>
   
   Root cause: Gravitino's type system has no native MULTISET type. The Paimon 
catalog backend converted `MULTISET<T>` to `MapType<T, INT>`, which was then 
converted to Flink's `MAP<T, INT NOT NULL>`. Paimon's `FlinkTableFactory` 
performs a strict schema comparison and rejects the mismatch.
   
   Fix: #10920
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. This is a bug fix that restores correct behavior for Paimon tables with 
MULTISET columns.
   
   ### How was this patch tested?
   
   - Added unit test `testMultisetTypeConversion` in `TestTypeUtils` covering 
both `toGravitinoType(MULTISET)` and `toFlinkType(ExternalType)` round-trip.
   - All existing unit tests pass for both `flink-connector` and 
`catalog-lakehouse-paimon` modules.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to