lucasgameiroborges opened a new issue, #18100:
URL: https://github.com/apache/iceberg/issues/18100
### Apache Iceberg version
1.10.0
### Query engine
Flink
### Please describe the bug 🐞
**Component: Flink / DynamicIcebergSink**
**Versions:**
- Apache Iceberg: 1.10.0 (iceberg-flink-runtime-2.0), also present on
`main` (v2.1/v2.2/v2.3 flink modules carry the same line)
- Apache Flink: 2.0
**Description:**
The Flink `DynamicIcebergSink` rebuilds a record whenever the incoming row's
schema is not byte-identical to the target table's schema (column-order
different, missing optional column, widening type) and that rebuild happens in
`DataConverter.RowDataConverter.convert()`:
[LINK](https://github.com/apache/iceberg/blob/main/flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/DataConverter.java#L172)
```java
GenericRowData targetData = new GenericRowData(fieldGetters.length);
```
`GenericRowData(int)` defaults RowKind to `INSERT` instead of propagating
the proper kind. Nothing else ever calls `setRowKind()` on the result, so any
converted row comes out as `INSERT` regardless of the source row's actual kind
(`UPDATE_BEFORE`, `UPDATE_AFTER`, `DELETE`).
`BaseDeltaTaskWriter` (the Flink CDC delta writer) dispatches purely on
`RowKind`. So a CDC delete/tombstone that happens to go through this "needs
conversion" path (e.g. it doesn't yet carry every optional column the table now
has, or its columns are ordered differently) is silently treated as an insert.
**Root cause:**
`RowKind` is dropped when `RowDataConverter` allocates the replacement
`GenericRowData`.
**Fix:**
Carry the source row's kind onto the converted row:
```java
GenericRowData targetData = new GenericRowData(sourceData.getRowKind(),
fieldGetters.length);
```
### Willingness to contribute
- [x] I can contribute a fix for this bug independently
- [ ] I would be willing to contribute a fix for this bug with guidance from
the Iceberg community
- [ ] I cannot contribute a fix for this bug at this time
--
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]