退订
---- 回复的原邮件 ---- | 发件人 | 张胜军<15910621...@139.com> | | 发送日期 | 2024年6月28日 12:57 | | 收件人 | user-zh<user-zh@flink.apache.org> | | 主题 | 退订 | 退订 扫一扫, 快速添加名片到手机 -------------------------------------------------------------------------------- ----The following is the content of the forwarded email---- From:Yanquan Lv <decq12y...@gmail.com> To:user-zh <user-zh@flink.apache.org> Date:2024-06-26 16:46:05 Subject:Re: Re:cdc读取oracle数据如何解析 可以的,通过设置 debezium 的 decimal.handling.mode <https://debezium.io/documentation/reference/1.9/connectors/oracle.html#oracle-property-decimal-handling-mode> [1] 参数可以实现你的需求,转成 double 或者 string 来处理。 [1] https://debezium.io/documentation/reference/1.9/connectors/oracle.html#oracle-numeric-types ha.fen...@aisino.com <ha.fen...@aisino.com> 于2024年6月26日周三 16:35写道: Map<String, Object> customConverterConfigs = new HashMap<>() customConverterConfigs.put(JsonConverterConfig.DECIMAL_FORMAT_CONFIG, "numeric") PRICE是decimal 类型,按上面设置可以正常了,ID是NUMBER,还是显示"ID":{"scale":0,"value":"AQ=="} 我试了下,我的ID是1,base64后是MQ==,这个ID还不是base64以后的结果。 通过JsonDebeziumDeserializationSchema(true, customConverterConfigs)打印出来schema {"schema":{"type":"struct","fields":[{"type":"struct","fields":[{"type":"struct","fields":[{"type":"int32","optional":false,"field":"scale"},{"type":"bytes","optional":false,"field":"value"}],"optional":false,"name":"io.debezium.data.VariableScaleDecimal","version":1,"doc":"Variable scaled decimal","field":"ID"}, 那是不是有什么方法,把对应的字段类型先设置好传进去 发件人: Yanquan Lv 发送时间: 2024-06-26 14:46 收件人: user-zh 主题: Re: 回复:cdc读取oracle数据如何解析 你好,你的 ID 和 PRINCE 字段类型是 decimal 吗,decimal 默认的展示方式是使用 BASE64 处理 可以通过添加下面代码来让展示信息更直观。 Map<String, Object> customConverterConfigs = new HashMap<>() customConverterConfigs.put(JsonConverterConfig.DECIMAL_FORMAT_CONFIG, "numeric") JsonDebeziumDeserializationSchema schema = new JsonDebeziumDeserializationSchema(includeSchema, customConverterConfigs) ha.fen...@aisino.com <ha.fen...@aisino.com> 于2024年6月25日周二 17:26写道: 数据没问题 "ID" "NAME" "ADDTIME" "PRICE" 1 "aa" 2024-6-25 14:21:33 12.22 发件人: 15868861416 发送时间: 2024-06-25 17:19 收件人: user-zh@flink.apache.org 主题: 回复:cdc读取oracle数据如何解析 检查一下oracle中的DEBEZIUM.PRODUCTS这个表的数据,看你解析中有字符串 | | 博星 | | 15868861...@163.com | ---- 回复的原邮件 ---- | 发件人 | ha.fen...@aisino.com<ha.fen...@aisino.com> | | 发送日期 | 2024年06月25日 15:54 | | 收件人 | user-zh<user-zh@flink.apache.org> | | 主题 | cdc读取oracle数据如何解析 | 根据文档的代码 JdbcIncrementalSource<String> oracleChangeEventSource = new OracleSourceBuilder() .hostname("host") .port(1521) .databaseList("ORCLCDB") .schemaList("DEBEZIUM") .tableList("DEBEZIUM.PRODUCTS") .username("username") .password("password") .deserializer(new JsonDebeziumDeserializationSchema()) .includeSchemaChanges(true) // output the schema changes as well .startupOptions(StartupOptions.initial()) .debeziumProperties(debeziumProperties) .splitSize(2) .build() 返回的结果: {"before":null,"after":{"ID":{"scale":0,"value":"AQ=="},"NAME":"aa","ADDTIME":1719325293000,"PRICE":"BMY="},"source":{"version":"1.9.8.Final","connector":"oracle","name":"oracle_logminer","ts_ms":0,"snapshot":"false","db":"ORCL","sequence":null,"schema":"CDC","table":"ORDER_CDC","txId":null,"scn":"0","commit_scn":null,"lcr_position":null,"rs_id":null,"ssn":0,"redo_thread":null},"op":"r","ts_ms":1719301769186,"transaction":null} 如何解析?PRICE应该是数字,ID也是数字,这里显示的都不同