seatunnel icon indicating copy to clipboard operation
seatunnel copied to clipboard

[Bug] [connector-jdbc] The field which type is `int` and null value will always get 0 instead of null

Open IcebergXTY opened this issue 2 years ago • 2 comments

Search before asking

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

What happened

we transfer data from mysql to postgresql, below is the table structure

CREATE TABLE `field_deal_config` (
  `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  `data_source_id` int NOT NULL,
  `field_pool_id` int NOT NULL,
  `save_to_field_pool_id` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_field_deal_config_data_source` (`data_source_id`)
) ENGINE=InnoDB AUTO_INCREMENT=751 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

As the save_to_field_pool_id can be null, so there are many null values.But when we begin transfer, seatunnel will use getInt to get value, then save_to_field_pool_id will not be null but 0 in postgresql. I'm not sure is this a bug, but in my opinion, null value in mysql should also be null in postgresql, right?😁

SeaTunnel Version

2.3.1

SeaTunnel Config

# mysql2pgsql_field_deal_config.conf
env {
    execution {
        parallelism=1
    }
    job {
        mode=BATCH
    }
}
sink {
    jdbc {
        driver="org.postgresql.Driver"
        password="123"
        query="insert into field_deal_config(id,data_source_id,field_pool_id,save_to_field_pool_id) values(?,?,?,?)"
        url="jdbc:postgresql://127.0.0.1:5432/yqs?currentSchema=yqs_online"
        user=postgres
    }
}
source {
    jdbc {
        "connection_check_timeout_sec"=100
        driver="com.mysql.cj.jdbc.Driver"
        password="123"
        query="select id,data_source_id,field_pool_id,save_to_field_pool_id from field_deal_config"
        url="jdbc:mysql://127.0.0.1:3307/yqs_online?serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useLegacyDatetimeCode=false&useSSL=false&nullNamePatternMatchesAll=true&useUnicode=true&characterEncoding=UTF-8"
        user=root
    }
}

Running Command

./bin/seatunnel.sh --config ./template/mysql2pgsql_field_deal_config.conf -e local

Error Exception

No error

Flink or Spark Version

No response

Java or Scala Version

No response

Screenshots

No response

Are you willing to submit PR?

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

Code of Conduct

IcebergXTY avatar Apr 24 '23 07:04 IcebergXTY

Please assign this to me

choucmei avatar Apr 26 '23 08:04 choucmei

This issue has been automatically marked as stale because it has not had recent activity for 30 days. It will be closed in next 7 days if no further activity occurs.

github-actions[bot] avatar May 27 '23 00:05 github-actions[bot]

This issue has been closed because it has not received response for too long time. You could reopen it if you encountered similar problems in the future.

github-actions[bot] avatar Jun 05 '23 00:06 github-actions[bot]