修复时间:2026-08-11
影响组件:chunjun-connector-hdfs.jar 中 BaseHdfsOutputFormat.class
DM → HDFS Parquet 同步时 hdfswriter 抛:
com.dtstack.chunjun.throwable.WriteRecordException:
The [N] data data [M] precision and scale do not match the metadata:decimal(0, +I(...))
at HdfsParquetSyncConverter.lambda$createExternalConverter$5a0c37d$6(HdfsParquetSyncConverter.java:228)BaseHdfsOutputFormat.lambda$initVariableFields$0 派生 fullColumnTypeList 时,
调用链是 FieldConfig.getType().getType()(双重 getType)—— 拿到的是 TypeConfig
剥离 (p,s) 后的裸 "DECIMAL"。后续 HdfsParquetOutputFormat.buildSchema 调
ColumnTypeUtil.getDecimalInfo("decimal", DEFAULT(10,0)),因串里没有 ( )
落回默认 (10,0),导致 enforcePrecisionScale 失败。
把 lambda 中 TypeConfig.getType() 的 invokevirtual 改成 TypeConfig.toOriginTypeStr(),
后者会把 type+precision+scale 重新拼成 "DECIMAL(25,6)" 完整串。
CP 末尾追加 3 个条目(Utf8 "toOriginTypeStr"、NameAndType、Methodref),
改写 lambda 字节码 offset 4 处的 Methodref 索引。
文件 | 说明 |
|---|---|
| 原 class(12509 bytes, md5 |
| 改后 class(12537 bytes, md5 |
| 服务器端执行的 patch 脚本(自动备份 jar + 字节码改写 + 回写 zip) |
/opt/chunjun/chunjun-dist/connector/hdfs/chunjun-connector-hdfs.jar(已 patch)/opt/chunjun/chunjun-dist/connector/hdfs/chunjun-connector-hdfs.jar.bak_decimal_patchcp /opt/chunjun/chunjun-dist/connector/hdfs/chunjun-connector-hdfs.jar.bak_decimal_patch \
/opt/chunjun/chunjun-dist/connector/hdfs/chunjun-connector-hdfs.jar参考 D:\workspace\xgong\verify_patch.py:javap 反编译 patched class,
确认 lambda$initVariableFields$0 中 invokevirtual 已指向 TypeConfig.toOriginTypeStr。
见用户 auto-memory:
chunjun-decimal-precision-jar-patch.md — 完整根因 + patch 字节码细节chunjun-pipeline-debug-playbook.md — 排查 playbook原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。