apache / flink-cdc

Flink CDC is a streaming data integration tool

Home Page:https://nightlies.apache.org/flink/flink-cdc-docs-stable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mysql同步到starrocks时,当主键是bigint且有无符号时,会被识别为decimal类型,导致创建表失败

TPSHION opened this issue · comments

异常信息:
2024-03-09 20:00:20,014 ERROR com.starrocks.connector.flink.catalog.StarRocksCatalog [] - Failed to create table secret.secret, sql: CREATE TABLE IF NOT EXISTS secret.st_user_gift (
id DECIMAL(20, 0) NOT NULL,
giftId VARCHAR(150) NOT NULL,
uid DECIMAL(20, 0) NOT NULL,
num INT NOT NULL,
remain INT NOT NULL,
getSource VARCHAR(300) NOT NULL,
createTime DATETIME NOT NULL
) PRIMARY KEY (id)
DISTRIBUTED BY HASH (id)
PROPERTIES (
"fast_schema_evolution" = "true"
);
java.sql.SQLSyntaxErrorException: Getting analyzing error. Detail message: primary key column[id] type not supported: decimal(20, 0).
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[?:?]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[?:?]
at com.mysql.cj.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1335) ~[?:?]
at com.mysql.cj.jdbc.StatementImpl.executeLargeUpdate(StatementImpl.java:2084) ~[?:?]
at com.mysql.cj.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1246) ~[?:?]
at com.starrocks.connector.flink.catalog.StarRocksCatalog.executeUpdateStatement(StarRocksCatalog.java:470) ~[?:?]
at com.starrocks.connector.flink.catalog.StarRocksCatalog.createTable(StarRocksCatalog.java:250) ~[?:?]
at com.ververica.cdc.connectors.starrocks.sink.StarRocksMetadataApplier.applyCreateTable(StarRocksMetadataApplier.java:97) ~[?:?]
at com.ververica.cdc.connectors.starrocks.sink.StarRocksMetadataApplier.applySchemaChange(StarRocksMetadataApplier.java:71) ~[?:?]
at com.ververica.cdc.runtime.operators.schema.coordinator.SchemaRegistryRequestHandler.applySchemaChange(SchemaRegistryRequestHandler.java:82) ~[?:?]

i want to fix this issue

Flink only have bigint type, if mysql data is unsigned bigint , maybe out of range, so cast to DECIMAL(20, 0).

If starrocks supports unsigned bigint, maybe can transform DECIMAL(20, 0) to unsigned bigint in sink. To be honest, unsigned bigint is not in SQL standard, thus many databases maybe not support it. https://docs.starrocks.io/zh/docs/sql-reference/sql-statements/data-types/data-type-list/

And starrock not support DECIMAL as primary key, thus should be transformed to String. I think we can fix it.

@TPSHION it's hard to say, which depends on whether state is compatibility. If only change some config, it's no problem.But if the pipeline is changes, maybe not restore from state.

Considering collaboration with developers around the world, please re-create your issue in English on Apache Jira under project Flink with component tag Flink CDC. Thank you!