waterWang opened a new pull request, #17631:
URL: https://github.com/apache/iceberg/pull/17631
Flink: DynamicIcebergSink throws UnsupportedOperationException for VARIANT
columns
## Problem
When using `DynamicIcebergSink` to write to an Iceberg table containing a
VARIANT column, the following exception is thrown:
```
Caused by: java.lang.UnsupportedOperationException: Unsupported type: variant
at org.apache.iceberg.schema.SchemaWithPartnerVisitor.variant(...)
at org.apache.iceberg.flink.sink.dynamic.CompareSchemasVisitor.visit(...)
```
The root cause is that `CompareSchemasVisitor` and `EvolveSchemaVisitor`
extend `SchemaWithPartnerVisitor` but do not override the `variant()` method,
which by default throws `UnsupportedOperationException`.
## Changes
Applied the fix to all three Flink versions (v1.20, v2.0, v2.1):
1. **CompareSchemasVisitor.java** — Added `variant()` override that treats
an existing VARIANT field as `Result.SAME`, and a missing field as
`Result.SCHEMA_UPDATE_NEEDED`.
2. **EvolveSchemaVisitor.java** — Added `variant()` override that returns
`false` (no evolution needed) when the VARIANT field already exists, and `true`
(field is missing) when it doesn't.
3. **DataConverter.java** — Added `case VARIANT:` to the `get()` switch
statement to handle VARIANT type identity conversion, preventing a secondary
`UnsupportedOperationException` if `DATA_CONVERSION_NEEDED` is reached for a
VARIANT field.
## Testing
- The fix follows the existing patterns for `primitive()` and other type
handlers in the respective visitors.
- DataConverter's VARIANT case returns identity conversion (no
transformation needed), consistent with how other pass-through types (BOOLEAN,
INTEGER, VARCHAR, etc.) are handled.
Closes #17615
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]