beansandroasters opened a new pull request, #4640: URL: https://github.com/apache/flink-cdc/pull/4640
## What is the purpose of this pull request? JIRA: https://issues.apache.org/jira/browse/FLINK-41774 (related: FLINK-41775, Iceberg sink ARRAY support) The MySQL pipeline source declares `SET` columns as `ARRAY<STRING>` in the table schema (`MySqlTypeUtils`), but writes their values into the records as `STRING`. The record type is inferred from the Debezium value schema, and Debezium represents a `SET` value as a comma separated string (`io.debezium.data.EnumSet`), which `DebeziumSchemaDataTypeInference` maps to `STRING`. Any sink that reads the column with the declared type then reads string bytes as an array. With the Iceberg sink (with the ARRAY support of the related PR) the job fails on the first row: ``` java.lang.IndexOutOfBoundsException at org.apache.flink.core.memory.MemorySegment.getInt(MemorySegment.java:801) at org.apache.flink.cdc.common.data.binary.BinarySegmentUtils.getInt(BinarySegmentUtils.java:632) at org.apache.flink.cdc.common.data.binary.BinaryArrayData.pointTo(BinaryArrayData.java:181) at org.apache.flink.cdc.common.data.binary.BinarySegmentUtils.readArrayData(BinarySegmentUtils.java:1195) at org.apache.flink.cdc.common.data.binary.BinaryRecordData.getArray(BinaryRecordData.java:207) ``` Reproduction: ```sql CREATE TABLE items (id INT PRIMARY KEY, title VARCHAR(64)); -- pipeline: MySQL source -> Iceberg sink ALTER TABLE items ADD COLUMN tags SET('a', 'b', 'c'); INSERT INTO items VALUES (2, 'cup', 'a,b'); ``` Expected: `2, cup, [a, b]`. Actual: the job fails. The SQL connector (`MySqlDeserializationConverterFactory`) already converts `SET` to `ARRAY<STRING>` by splitting the string; the pipeline source does not. Affected versions: 3.7.0 and master. ## Brief change log - `MySqlSchemaDataTypeInference#inferString`: infer `ARRAY<STRING>` for `io.debezium.data.EnumSet`, matching `MySqlTypeUtils`. - `MySqlEventDeserializer#convertToArray`: split the `SET` string into an array of strings; the empty set becomes an empty array. This PR does not depend on the Iceberg ARRAY PR; it makes the records match the schema the source already declares. --- ## Verifying this change This change added tests and can be verified as follows: - Added unit test `MySqlEventDeserializerSetTypeTest`: type inference and record conversion of `SET` values (two values, empty set, null). Both tests fail without the fix, one with the `IndexOutOfBoundsException` above. - `mvn verify -pl flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-mysql` (spotless, checkstyle, all 47 unit tests and 62 integration tests of the module, including `MySqlFullTypesITCase` and `MySqlPipelineITCase`) passes with the default Flink 1.20 profile and with `-Pflink2` (JDK 11). - 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 Iceberg ARRAY PR, running the SQL above: the row is written as `2, cup, [a, b]`. This end-to-end test is not part of this PR. ## Documentation - Does this pull request introduce a new feature? (no) - If yes, how is the feature documented? (not applicable) --- ##### 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]
