beansandroasters opened a new pull request, #4641:
URL: https://github.com/apache/flink-cdc/pull/4641

   
   ## What is the purpose of this pull request?
   
   JIRA: https://issues.apache.org/jira/browse/FLINK-41775 (related: 
FLINK-41774, MySQL SET values)
   
   The Iceberg pipeline sink does not support the `ARRAY` type, and the failure 
stops the pipeline.
   
   The MySQL pipeline source maps MySQL `SET` columns to `ARRAY<STRING>` 
(`MySqlTypeUtils`), so this can be reached with ordinary DDL:
   
   ```sql
   CREATE TABLE users (id BIGINT PRIMARY KEY, name VARCHAR(64));
   -- pipeline: MySQL source -> Iceberg sink, schema.change.behavior: evolve
   ALTER TABLE users ADD COLUMN roles SET('admin', 'editor');
   INSERT INTO users VALUES (1, 'alice', 'admin,editor');
   ```
   
   Expected: the row `1, alice, [admin, editor]` is written to the Iceberg 
table.
   
   Actual:
   
   - `ADD COLUMN` succeeds (the sink converts the type with `FlinkSchemaUtil`, 
so the Iceberg table gets a `list<string>` column), but every subsequent write 
fails in `IcebergTypeUtils.createFieldGetter` with 
`java.lang.IllegalArgumentException: don't support type of ARRAY`. The job 
keeps failing over and no further changes are written.
   - If the source table already has a `SET` column when the pipeline starts, 
`CreateTableEvent` fails with `Unsupported cdc type in iceberg: ARRAY<STRING>` 
(`IcebergTypeUtils.convertCDCTypeToIcebergType`).
   
   Affected versions: 3.7.0 and master.
   
   For MySQL `SET` columns end to end, a second fix in the MySQL source is 
needed as well: the source declares `ARRAY<STRING>` but writes the values as 
`STRING` (separate PR, "[connect/mysql] Emit MySQL SET values as ARRAY<STRING> 
in the pipeline source"). This PR does not depend on it and fixes the sink for 
any source that produces `ARRAY` columns.
   
   ## Brief change log
   
   - `IcebergTypeUtils.convertCDCTypeToIcebergType` maps `ARRAY<T>` to Iceberg 
`LIST<T>` (optional or required element according to the element nullability). 
Nested field ids are taken from a supplier; the existing overloads keep their 
behavior.
   - `IcebergMetadataApplier.applyCreateTable` passes a supplier that starts 
after the top-level column ids, so nested element ids never collide with column 
ids.
   - `IcebergTypeUtils.createFieldGetter` supports `ARRAY`: the elements are 
converted from Flink CDC internal data to Flink internal data (strings, 
numerics, decimals, timestamps, nested arrays, null elements).
   - Docs (en/zh): add `ARRAY` to the data type mapping table of the Iceberg 
connector.
   
   `MAP` and `ROW` element types are not part of this change.
   
   ---
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
   - Added unit test `IcebergWriterTest#testWriteAfterAddingArrayColumn`: adds 
an `ARRAY<STRING>` column through `AddColumnEvent` and writes a row. Fails 
without the fix with `don't support type of ARRAY`.
   - Added unit test 
`IcebergWriterTest#testWriteArrayColumnsFromCreateTableAndAddColumn`: creates a 
table with `ARRAY<STRING>` and `ARRAY<INT>` columns, writes rows with null 
arrays and null elements, then adds another array column. Fails without the fix 
with `Unsupported cdc type in iceberg: ARRAY<STRING>`.
   - `mvn verify -pl 
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-iceberg`
 (spotless, checkstyle, unit tests and `IcebergSinkITCase`) passes on JDK 11, 
both with the default Flink 1.20 profile and with `-Pflink2`.
   - Manually tested with a MySQL 8.0 container → Flink → Iceberg Hadoop 
catalog pipeline (Flink 1.20.3 and 2.2.0, parallelism 1 and 4), together with 
the MySQL `SET` PR, running the SQL above. This end-to-end test is not part of 
this PR.
   
   ## Documentation
   
   - Does this pull request introduce a new feature? (yes)
   - If yes, how is the feature documented? (docs)
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Claude Code 2.1.300 (Claude Opus 5.5)
   


-- 
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