如何从Parquet文件中将键值对(MAP)加载到Athena中?

问题描述 投票:0回答:1

我有一个充满.gz.parquet文件的S3存储桶。我想让他们在雅典娜访问。为此,我要在雅典娜中创建一个指向s3存储桶的表:

CREATE EXTERNAL TABLE user_db.table (
pan_id bigint,
dev_id bigint,
parameters ?????, 
start_time_local bigint
                                     )
STORED AS PARQUET
LOCATION ‘s3://bucket/path/to/folder/containing_files/’
tblproperties (“parquet.compression”=“GZIP”)
;

如何正确指定参数列的数据类型?

使用# parquet-tools schema,我看到了数据文件的以下架构:

  optional int64 pan_id;
  optional int64 dev_id;
  optional group parameters (MAP) {
    repeated group key_value {
      required binary key (UTF8);
      optional binary value (UTF8);
    }
  }
  optional int96 start_time_local;

使用# parquet-tools head,我看到一行数据的以下值:

pan_id = 1668490
dev_id = 6843371
parameters:
.key_value:
..key = doc_id
..value = c2bd3593d7015fb912d4de229a302379babcf6a00a203fcf
.key_value:
..key = variables
..value = {“video_id”:“2313675068886132",“surface”:“post”}
start_time_local = QFOHvvYvAAAzhCUA

我感谢您能提供的任何帮助。我无法找到有关CREATE TABLE中使用的MAP数据类型的良好文档。

key-value parquet create-table amazon-athena sqldatatypes
1个回答
0
投票

您可以使用AWS Glue爬网程序从Parquet文件中自动派生架构。

[定义AWS Glue抓取工具:https://docs.aws.amazon.com/glue/latest/dg/add-crawler.html

© www.soinside.com 2019 - 2024. All rights reserved.