问题描述
简要描述遇到的问题。
result.sinks format=table 情况下column 指定 columnType = 非字符串类型,结果插入数据库会报错
复现步骤
- 配置文件内容(脱敏后):
source:
type: postgresql
name: source-postgresql
connection:
url: jdbc:postgresql://localhost:5432/bh
username: postgres
password: 123456
resource:
type: table
name: base_device_monitor_bind
target:
type: postgresql
name: target-postgresql
connection:
url: jdbc:postgresql://localhost:5432/bh_local
username: postgres
password: 123456
resource:
type: table
name: base_device_monitor_bind
comparison:
keys:
source:
- id
target:
- id
fields:
source:
- device_id
- monitor_name
- device_monitor_id
- device_bind_id
- status
target:
- device_id
- monitor_name
- device_monitor_id
- device_bind_id
- status
strategy:
mode: checksum
algorithm: xor
bisectionFactor: 4
bisectionThreshold: 5000
result:
sinks:
- format: console
type: result
- format: table
type: diff-record
properties:
url: jdbc:postgresql://localhost:5432/test
username: postgres
password: 123456
driver: org.postgresql.Driver
maxPoolSize: 10
tableName: diff_result
createTable: true
batchSize: 1000
columns:
- name: task_id
value: ${taskId}
- name: diff_type
value: ${operation}
- name: pk_value
value: ${primaryKey}
- name: device_id
value: ${src.device_id}
- name: monitor_name
value: ${tgt.monitor_name}
- 执行命令:
./bin/consilens-cli.sh diff --config config.yaml
- 观察到的错误:
2026-04-30 23:08:24.621 [main] WARN com.consilens.sink.api.SinkManager - Sink execution failed: Batch entry 0 INSERT INTO diff_result1 (task_id, diff_type, pk_value, device_id, monitor_name) VALUES ('683e99b8-3b4d-43c1-a53d-36a641af176d','mismatch','1','1','状态') was aborted: ERROR: column "device_id" is of type bigint but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 99 Call getNextException to see other errors in the batch.
期望行为
描述你期望看到的正确行为。
List fields = sinkConfig.getColumns();
for (int i = 0; i < fields.size(); i++) {
ps.setString(i + 1, ColumnValueInterpolator.resolveField(fields.get(i), context, row));
}
fields 中device_id 中数据类型config.yaml 中指定了 int8, 但是ps.string(,),方法使用的是字符串导致了 ? 填充的数据和期望的数据类型不一致。
环境信息
- Consilens 版本: [e.g., 0.1-SNAPSHOT]
- JDK 版本: [e.g., 11.0.21]
- 操作系统: [e.g., windows]
- 源数据库: [e.g., PostgreSQL]
- 目标数据库: [e.g., PostgreSQL]
日志输出
粘贴相关日志(请移除敏感信息)
2026-04-30 23:08:24.621 [main] WARN com.consilens.sink.api.SinkManager - Sink execution failed: Batch entry 0 INSERT INTO diff_result1 (task_id, diff_type, pk_value, device_id, monitor_name) VALUES ('683e99b8-3b4d-43c1-a53d-36a641af176d','mismatch','1','1','状态') was aborted: ERROR: column "device_id" is of type bigint but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 99 Call getNextException to see other errors in the batch.
补充信息
其他有助于排查问题的信息。
非常感谢提供的学习类库,如非bug,请多多包含。
问题描述
简要描述遇到的问题。
result.sinks format=table 情况下column 指定 columnType = 非字符串类型,结果插入数据库会报错
复现步骤
2026-04-30 23:08:24.621 [main] WARN com.consilens.sink.api.SinkManager - Sink execution failed: Batch entry 0 INSERT INTO diff_result1 (task_id, diff_type, pk_value, device_id, monitor_name) VALUES ('683e99b8-3b4d-43c1-a53d-36a641af176d','mismatch','1','1','状态') was aborted: ERROR: column "device_id" is of type bigint but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 99 Call getNextException to see other errors in the batch.
期望行为
描述你期望看到的正确行为。
List fields = sinkConfig.getColumns();
for (int i = 0; i < fields.size(); i++) {
ps.setString(i + 1, ColumnValueInterpolator.resolveField(fields.get(i), context, row));
}
fields 中device_id 中数据类型config.yaml 中指定了 int8, 但是ps.string(,),方法使用的是字符串导致了 ? 填充的数据和期望的数据类型不一致。
环境信息
日志输出
补充信息
其他有助于排查问题的信息。
非常感谢提供的学习类库,如非bug,请多多包含。