S3 存储桶上的 AWS Athena 有一些 JSON 个文件
AWS Athena on S3 bucket with some JSON files
使用 AWS Athena 进行试验。我正在尝试从具有如下文件结构的 S3 存储桶创建 table:
my-bucket/
my-bucket/group1/
my-bucket/group1/entry1/
my-bucket/group1/entry1/data.bin
my-bucket/group1/entry1/metadata
my-bucket/group1/entry2/
my-bucket/group1/entry2/data.bin
my-bucket/group1/entry2/metadata
...
my-bucket-group2/
...
只有 metadata
个文件是 JSON 个文件。每一个看起来像这样:
{
"key1": "value1",
"key2": "value2",
"key3": n
}
所以我尝试创建一个 table:
CREATE EXTERNAL TABLE example (
key1 string,
key2 string,
key3 int
)
ROW FORMAT serde 'org.apache.hive.hcatalog.data.JsonSerDe'
LOCATION 's3://my-bucket/'
创建查询成功,但是当我尝试查询时:
SELECT * FROM preserved_recordings limit 10;
我收到一个错误:
Query 93aa62d6-8a52-4a5d-a2fb-08a6e00181d3 failed with error code HIVE_CURSOR_ERROR: org.codehaus.jackson.JsonParseException: Unexpected end-of-input: expected close marker for OBJECT (from [Source: java.io.ByteArrayInputStream@2da7f4ef; line: 1, column: 0]) at [Source: java.io.ByteArrayInputStream@2da7f4ef; line: 1, column: 3]
在这种情况下,AWS Athena 是否要求存储桶中的 所有 个文件为 JSON?我不确定是 .bin 文件导致了光标错误,还是其他原因。有没有其他人遇到过这个,或者可以告诉我发生了什么事?
是的,Athena(Presto、Hive)要求存储在 table's LOCATION 中的文件具有一致的格式。我相信您需要移动文件以便为每个基础数据模式创建单独的 tables。
最近我发现,如果你把文件放在优先级 _ 那么 hive 会忽略它们。因此,在您的示例中,您可以将文件重命名为 _data.bin,然后该文件将被忽略。
使用 AWS Athena 进行试验。我正在尝试从具有如下文件结构的 S3 存储桶创建 table:
my-bucket/
my-bucket/group1/
my-bucket/group1/entry1/
my-bucket/group1/entry1/data.bin
my-bucket/group1/entry1/metadata
my-bucket/group1/entry2/
my-bucket/group1/entry2/data.bin
my-bucket/group1/entry2/metadata
...
my-bucket-group2/
...
只有 metadata
个文件是 JSON 个文件。每一个看起来像这样:
{
"key1": "value1",
"key2": "value2",
"key3": n
}
所以我尝试创建一个 table:
CREATE EXTERNAL TABLE example (
key1 string,
key2 string,
key3 int
)
ROW FORMAT serde 'org.apache.hive.hcatalog.data.JsonSerDe'
LOCATION 's3://my-bucket/'
创建查询成功,但是当我尝试查询时:
SELECT * FROM preserved_recordings limit 10;
我收到一个错误:
Query 93aa62d6-8a52-4a5d-a2fb-08a6e00181d3 failed with error code HIVE_CURSOR_ERROR: org.codehaus.jackson.JsonParseException: Unexpected end-of-input: expected close marker for OBJECT (from [Source: java.io.ByteArrayInputStream@2da7f4ef; line: 1, column: 0]) at [Source: java.io.ByteArrayInputStream@2da7f4ef; line: 1, column: 3]
在这种情况下,AWS Athena 是否要求存储桶中的 所有 个文件为 JSON?我不确定是 .bin 文件导致了光标错误,还是其他原因。有没有其他人遇到过这个,或者可以告诉我发生了什么事?
是的,Athena(Presto、Hive)要求存储在 table's LOCATION 中的文件具有一致的格式。我相信您需要移动文件以便为每个基础数据模式创建单独的 tables。
最近我发现,如果你把文件放在优先级 _ 那么 hive 会忽略它们。因此,在您的示例中,您可以将文件重命名为 _data.bin,然后该文件将被忽略。