lvyanquan commented on PR #4641:
URL: https://github.com/apache/flink-cdc/pull/4641#issuecomment-7372895317
**Suggestion: `AlterColumnTypeEvent` for ARRAY columns should be a no-op
instead of failing the job**
With this change, creating and adding an `ARRAY` column works, but altering
a column whose type is `ARRAY` still fails. It is reachable from the MySQL
`SET` scenario that motivates this PR (with `schema.change.behavior: evolve`):
```sql
ALTER TABLE users ADD COLUMN roles SET('admin','editor'); --
AddColumnEvent: OK
ALTER TABLE users MODIFY COLUMN roles SET('admin','editor','viewer'); --
fails
```
The MySQL pipeline source emits an `AlterColumnTypeEvent` for every
`MODIFY`/`CHANGE` of a `SET` column, even when the CDC type does not actually
change (`SET` always maps to `ARRAY<STRING>`; the member list is not part of
the type). In the sink, `IcebergMetadataApplier#applyAlterColumnType` then
calls `FlinkSchemaUtil.convert(...).asPrimitiveType()`, which throws
`IllegalArgumentException: Not a primitive type: list<string>`, is wrapped into
a `SchemaEvolveException`, and fails the pipeline. Note the type before and
after is `ARRAY<STRING>` in this case, so the Iceberg schema does not need to
change at all.
Iceberg's `UpdateSchema#updateColumn` only accepts `Type.PrimitiveType`
(there is no nested type promotion), so an array can never be "updated" through
this path. Suggested handling:
- if the new type is not primitive, compare it with the current Iceberg
field type and skip the update when they are equivalent (ignoring field ids),
e.g. `ARRAY<STRING> -> ARRAY<STRING>`;
- otherwise fail with a clear "unsupported schema change" error (e.g. a
`SET` column changed to `VARCHAR`, which would require `list<string> ->
string`).
It would be great to add a test that applies
`AlterColumnTypeEvent(ARRAY<STRING> -> ARRAY<STRING>)` after the table is
created, so `MODIFY SET(...)` cannot break an otherwise ARRAY-capable pipeline.
--
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]