[ 
https://issues.apache.org/jira/browse/FLINK-41775?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18153838#comment-18153838
 ] 

Kensuke Fukumoto commented on FLINK-41775:
------------------------------------------

Hi, I'd like to work on this issue. Could someone assign it to me?

My understanding: IcebergTypeUtils#convertCDCTypeToIcebergType rejects ARRAY, 
and IcebergTypeUtils#createFieldGetter throws "don't support type of ARRAY", so 
a CreateTableEvent with an array column fails, and an AddColumnEvent with one 
succeeds but every following write fails.

Proposed change: map ARRAY<T> to Iceberg LIST<T> (element optional or required 
following the element nullability), assign nested field ids after the top-level 
column ids in applyCreateTable so they never collide, and convert array values 
in the field getter. MAP and ROW are out of scope for this issue. The docs 
(en/zh) data type mapping table is updated as well.

I have a fix with unit tests that fail on master and pass with the change; the 
module tests and IcebergSinkITCase pass on both Flink 1.20 and -Pflink2. For 
MySQL SET columns, FLINK-41774 is needed as well. I'll open a PR once the issue 
is assigned.


> [pipeline-connector/iceberg] Iceberg sink fails on ARRAY columns
> ----------------------------------------------------------------
>
>                 Key: FLINK-41775
>                 URL: https://issues.apache.org/jira/browse/FLINK-41775
>             Project: Flink
>          Issue Type: Bug
>          Components: Flink CDC
>    Affects Versions: cdc-3.7.0
>         Environment: Flink CDC 3.7.0 and master (d7f6adedd85c), Flink 1.20.3 
> and 2.2.0, Iceberg 1.10.1, MySQL 8.0
>            Reporter: Kensuke Fukumoto
>            Priority: Major
>
> h2. Description
> The Iceberg pipeline sink does not support the Flink CDC {{ARRAY}} type:
> * {{IcebergTypeUtils.convertCDCTypeToIcebergType}} throws {{Unsupported cdc 
> type in iceberg: ARRAY<STRING>}}, so a {{CreateTableEvent}} with an array 
> column fails.
> * {{AddColumnEvent}} with an array column succeeds (the type is converted 
> with {{FlinkSchemaUtil}}, and the Iceberg table gets a {{list<string>}} 
> column), but {{IcebergTypeUtils.createFieldGetter}} throws {{don't support 
> type of ARRAY}}, so every following write fails and the job keeps failing 
> over.
> This is reachable with ordinary DDL, because the MySQL pipeline source maps 
> {{SET}} columns to {{ARRAY<STRING>}}.
> Proposed fix: map {{ARRAY<T>}} to Iceberg {{LIST<T>}} (nested field ids 
> assigned after the top-level column ids) and convert array values in the 
> field getter. {{MAP}} and {{ROW}} are out of scope.
> h2. Steps to reproduce
> # Start a pipeline {{MySQL source -> Iceberg sink}} with 
> {{schema.change.behavior: evolve}} on:
> {code:sql}
> CREATE TABLE users (id BIGINT PRIMARY KEY, name VARCHAR(64));
> {code}
> # Run:
> {code:sql}
> ALTER TABLE users ADD COLUMN roles SET('admin', 'editor');
> INSERT INTO users VALUES (1, 'alice', 'admin,editor');
> {code}
> # Expected: the row {{(1, alice, [admin, editor])}} in the Iceberg table.
>    Actual: {{java.lang.IllegalArgumentException: don't support type of 
> ARRAY}} from {{IcebergTypeUtils.createFieldGetter}}, and the job keeps 
> failing over.
> # Alternatively, create the table with the {{SET}} column before starting the 
> pipeline: the {{CreateTableEvent}} fails with {{Unsupported cdc type in 
> iceberg: ARRAY<STRING>}}.
> For MySQL {{SET}} columns the linked MySQL source issue has to be fixed as 
> well; this issue covers the sink for any source that produces {{ARRAY}} 
> columns.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to