gpt4 book ai didi

amazon-athena - 为 athena 选择特定文件

转载 作者:行者123 更新时间:2023-12-03 14:10:04 26 4
gpt4 key购买 nike

在 Athena 中创建表时,我无法使用特定文件创建表。有没有办法从给定的存储桶中选择以“year_2019”开头的所有文件?例如
s3://bucketname/prefix/year_2019*.csv

文档对此非常清楚,这是不允许的。

从:
https://docs.aws.amazon.com/athena/latest/ug/tables-location-format.html

Athena reads all files in an Amazon S3 location you specify in the CREATE TABLE statement, and cannot ignore any files included in the prefix. When you create tables, include in the Amazon S3 path only the files you want Athena to read. Use AWS Lambda functions to scan files in the source location, remove any empty files, and move unneeded files to another location.



我想知道社区是否找到了一些解决方法:)

最佳答案

不幸的是,Athena 用于 S3 的文件系统抽象不支持这一点。它要求表位置看起来像目录,当列出文件时,Athena 会在位置的末尾添加一个斜杠。

有一种方法可以创建只包含选定文件的表,但据我所知它不支持通配符,只支持显式的文件列表。

你要做的是创建一个表

STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.SymlinkTextInputFormat'

然后而不是指向 LOCATION表的实际文件,您将其指向带有单个 symlink.txt 的前缀文件(或将每个分区指向带有单个 symlink.txt 的前缀)。在 symlink.txt文件,您添加要包含在表中的文件的 S3 URI,每行一个。

我所知道的有关此功能的唯一文档是 S3 Inventory documentation for integrating with Athena .

您还可以在此 Stackoverflow 响应中找到完整示例: https://stackoverflow.com/a/55069330/1109

关于amazon-athena - 为 athena 选择特定文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55134724/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com