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

CleanDuplicativeSchema工具

功能说明

清理最新的.schemacommit文件中重复的schema。当schema演进过程中相邻版本的InternalSchema内容完全相同(结构相同但schemaId不同)时,此工具进行去重,只保留去重后的schema条目。

约束

  • 仅操作最新的.schemacommit文件,不处理历史文件。
  • 如果.hoodie/.schema/目录不存在(未启用schema evolution),check和fix均返回No problems found.

命令格式

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

参数说明

参数

是否必选

参数说明

${命令}

是

  • check:检测最新的.schemacommit文件中是否存在重复的schema。
  • fix:备份并清理文件内重复的schema。
  • restore:对备份文件进行恢复,恢复到清理前的状态。
  • cleanbackup:删除备份文件。

${库名.表名}

是

需要处理的Hudi表名,格式为库名.表名。

输出结果说明

字段

说明

RESULT

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

MESSAGE

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

使用样例

  • 检查是否存在重复schema:
    spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \
    --class com.huawei.mrs.hudi.tools.CleanDuplicativeSchema \
    /opt/hudi-fix-tools-1.0.jar \
    check mydb.mytable
  • 清理重复schema(自动备份):
    spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \
    --class com.huawei.mrs.hudi.tools.CleanDuplicativeSchema \
    /opt/hudi-fix-tools-1.0.jar \
    fix mydb.mytable
  • 恢复备份:
    spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \
    --class com.huawei.mrs.hudi.tools.CleanDuplicativeSchema \
    /opt/hudi-fix-tools-1.0.jar \
    restore mydb.mytable
  • 清理备份:
    spark-submit --master yarn --driver-memory 2G --num-executors 3 --executor-memory 4G \
    --class com.huawei.mrs.hudi.tools.CleanDuplicativeSchema \
    /opt/hudi-fix-tools-1.0.jar \
    cleanbackup mydb.mytable

相关文档