首页 > 解决方案 > 在 parquet 数据类型问题中使用 alluxio 存储的 Hive Metastore

问题描述

我使用 prestodb 和 hive 元存储作为模式存储,alluxio 缓存作为数据的外部存储。alluxio 和 hive 模式中使用的存储格式是PARQUET。使用 hive 目录从 presto 检索时间戳字段时。我得到跟随错误。

utdate 列被声明为类型timestamp,但Parquet文件将该列声明为INT64类型

数据集的架构是

创建表测试(utcdate 时间戳) WITH(格式='PARQUIET',external_location='alluxio://path-toserver/directory-path-to-parquet')

此问题是从 prestodb v0.221升级到v0.226版本后产生的。

标签: hiveparquetprestoalluxio

解决方案


我在保存镶木地板时使用它来解决时间戳问题。

pyarrow.parquet.write_table(self.arrow_table, file_name, use_deprecated_int96_timestamps=True)

presto 和 spark 使用 int96 时间戳值以纳秒为单位存储时间戳。pyarrow table 的默认时间戳格式是 int64,而 presto 将 int64 视为 bigint 数据类型。如果我们在 pyarrow 中使用不推荐使用的时间戳 int96 版本,我们将获得 presto 兼容格式的时间戳值。


推荐阅读