doris-flink-connector icon indicating copy to clipboard operation
doris-flink-connector copied to clipboard

[Bug] Mysql bit 类型字段生成Doris schema 错误

Open laizuan opened this issue 1 year ago • 5 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Version

flink-doris-connector-1.18-1.5.2.jar flink: 1.18.1 mysql: 8.0 doris: 2.0.5

What's Wrong?

数据库字段xxx是bit类型,并且不为空。生成Doris预计如下:

CREATE TABLE IF NOT EXISTS `xx`.`xx`(
  `id` BIGINT COMMENT '主键',
  `xxx` BOOLEAN DEFAULT 'b' 0 '' COMMENT 'xxx'
) UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS AUTO PROPERTIES (
  'replication_num' = '1',
  'light_schema_change' = 'true'
)

在控制执行SQL后的异常:

Failed to execute sql: org.apache.doris.common.AnalysisException: errCode = 2, detailMessage = Syntax error in line 3:
  `xxx` BOOLEAN DEFAULT 'b' 0 '' COMMENT 'xxx'
                                               ^
Encountered: INTEGER LITERAL
Expected: COMMA

What You Expected?

CREATE TABLE IF NOT EXISTS `cm`.`xx`(
  `id` BIGINT COMMENT '主键',
  `xxx` BOOLEAN DEFAULT 'false' COMMENT 'xxx'
) UNIQUE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS AUTO PROPERTIES (
  'replication_num' = '1',
  'light_schema_change' = 'true'
)

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • [ ] Yes I am willing to submit a PR!

Code of Conduct

laizuan avatar Mar 06 '24 08:03 laizuan

mysql是bit,对应flink的是BINARY(⌈(n + 7) / 8⌉),可以用flink的DECODE(binary, string)函数试试

zhbdesign avatar Mar 07 '24 02:03 zhbdesign

@laizuan can you provide the ddl of mysql source table?

vinlee19 avatar Mar 12 '24 10:03 vinlee19

@laizuan can you provide the ddl of mysql source table?

@vinlee19 DDL after desensitization


CREATE TABLE `x`.`xxx`  (
  `id` bigint NOT NULL COMMENT '主键',
  `xxx` bit(1) NOT NULL COMMENT 'xxx',
   ......other fields
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

laizuan avatar Mar 12 '24 11:03 laizuan

The main issue is the mismatch between the default values of MySQL and Doris, resulting in DDL errors. Solutions: 1. Use Flink Connector version 1.5.1. 2. Wait for the next version to fix it.

vinlee19 avatar Mar 12 '24 12:03 vinlee19

thks

The main issue is the mismatch between the default values of MySQL and Doris, resulting in DDL errors. Solutions: 1. Use Flink Connector version 1.5.1. 2. Wait for the next version to fix it.

thks

laizuan avatar Mar 13 '24 01:03 laizuan