微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将基于 Hudi 时间戳的分区表同步到 hive 时,分区列类型不匹配

如何解决将基于 Hudi 时间戳的分区表同步到 hive 时,分区列类型不匹配

我正在尝试编写一个分区的 hudi 表并同步到 hive Metatore。我是TimestampBasedKeyGenerator。源 spark 数据帧的 dt 列包含长时间时间戳值。

hudioptions are as follow:
hudioptions += (
    DataSourceWriteOptions.HIVE_SYNC_ENABLED_OPT_KEY -> "true",DataSourceWriteOptions.HIVE_USE_JDBC_OPT_KEY -> "false",DataSourceWriteOptions.PARTITIONPATH_FIELD_OPT_KEY -> "dt",DataSourceWriteOptions.KEYGENERATOR_CLASS_OPT_KEY -> classOf[TimestampBasedKeyGenerator].getName,DataSourceWriteOptions.HIVE_PARTITION_FIELDS_OPT_KEY -> "dt",DataSourceWriteOptions.HIVE_STYLE_PARTITIONING_OPT_KEY -> "true",DataSourceWriteOptions.HIVE_PARTITION_EXTRACTOR_CLASS_OPT_KEY -> classOf[MultiPartKeysValueExtractor].getName,"hoodie.deltastreamer.keygen.timebased.output.dateformat" -> "yyyy-MM-dd","hoodie.deltastreamer.keygen.timebased.timestamp.type" -> "EPOCHMILLISECONDS"
)

我收到此错误

Failed: SemanticException [Error 10248]: Cannot add partition column dt of type string as it cannot be converted to type bigint
20/12/30 15:10:53 ERROR Driver: Failed: SemanticException [Error 10248]: Cannot add partition column dt of type string as it cannot be converted to type bigint
org.apache.hadoop.hive.ql.parse.SemanticException: Cannot add partition column dt of type string as it cannot be converted to type bigint

问题:

  1. 为什么会发生此错误以及如何解决
  2. 当我使用 spark.table("{tableName}").printSchema 获取表架构时,我得到了 dt: long (nullable = true), 但是当我使用 spark.read.format("org.apache.hudi").load("{path}").printSchema" 获取表架构时,我得到了 dt: date (nullable = true)。 为什么 dt 的数据类型在这里不同?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。