更新时间:2026-10-28 GMT+08:00
分享

CheckWriteSchema工具

功能说明

检测最新写入数据的schema与Hudi表schema是否一致。从最近一次UPSERT/INSERT写入的数据文件中提取schema,与表定义的schema进行比对。

命令格式

spark-submit \
--master yarn \
--driver-memory 2G \
--num-executors 3 \
--executor-memory 4G \
--class com.huawei.mrs.hudi.tools.CheckWriteSchema \
/opt/hudi-fix-tools-1.0.jar \
${库名.表名}

参数说明

参数

是否必选

参数说明

${库名.表名}

是

需要检查的Hudi表名,格式为库名.表名。

输出结果说明

字段

说明

RESULT

success表示执行成功,failed表示执行失败。

MESSAGE

检测、执行结果信息或执行失败信息。

MESSAGE含义:

MESSAGE

级别

说明

处理建议

No problems found.

正常

写入schema与最新表schema一致。

无需处理。

Write schema is not the same with the latest table schema.

WARN

表schema发生了变更,入湖作业没有相应的做变更。

理论上不影响表的查询,需要修改入湖作业或通过SQL回退表schema变更。

Write schema is not the same with table schema.

ERROR

入湖作业schema发生了变更且与表schema不一致。

已写入的数据大概率会影响表的查询,需要调整入湖作业的schema;如影响可通过ForceRollback回滚。

使用样例

  • 检查写入schema是否一致:
    spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \
    --class com.huawei.mrs.hudi.tools.CheckWriteSchema \
    /opt/hudi-fix-tools-1.0.jar \
    mydb.mytable
  • 忽略optional/nullable差异进行检查:
    spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \
    --conf spark.hudi.check.schema.ignore.optional=true \
    --class com.huawei.mrs.hudi.tools.CheckWriteSchema \
    /opt/hudi-fix-tools-1.0.jar \
    mydb.mytable

相关文档