Kensuke Fukumoto created FLINK-41775:
----------------------------------------

             Summary: [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


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