如何将 AWS Athena 连接到现有的 Hive Metastore

How to connect AWS Athena to an exists Hive Metastore

我需要将 AWS Athena 服务与现有的 Hive Metastore(不是 AWS Glue)集成。

能否告诉我如何将 Athena 连接到 Hive Metastore。

Athena 仅适用于其自己的元存储或相关的 AWS Glue 元存储。它不适用于外部元存储。

但是,您可以在同一底层 S3 存储上设置多个 table 或数据库。因此,如果您使用外部元存储将数据写入 S3,则在设置适当的数据库和 Athena 元存储中的 table 定义后,您可以使用 Athena 查询这些文件。

另一种方法是使用命令

将配置单元元数据导出到文件

command="hive -f "+schema+"_tables.hql -S >> "+schema+".output"

其中要导出 schema= 并使用 python 中的 groovy 将 table 定义导入 Athena。

设置 groovy 的说明可以在 link

中找到

https://github.com/aws-samples/aws-big-data-blog/tree/master/aws-blog-athena-importing-hive-metastores

Amazon Athena 刚刚发布了一项新功能(目前处于预览状态),允许您将 Athena 连接到 Apache Hive Metastore。可以看到公告here. Detailed steps to add the Hive Metastore connector are available in the Athena documentation