如何从 Parquet 文件将键值对 (MAP) 加载到 Athena 中?
How to load key-value pairs (MAP) into Athena from Parquet file?
我有一个装满 .gz.parquet 文件的 S3 存储桶。我想让它们在 Athena 中可用。为此,我在 Athena 中创建了一个指向 s3 存储桶的 table:
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 数据类型的良好文档
您可以使用 AWS Glue 爬虫从您的 Parquet 文件中自动派生架构。
定义 AWS Glue 爬虫:https://docs.aws.amazon.com/glue/latest/dg/add-crawler.html
映射被声明为 map<string,string>
(对于字符串到字符串的映射,其他类型也是可能的),在您的情况下,整个 table DDL 将是:
CREATE EXTERNAL TABLE user_db.table (
pan_id bigint,
dev_id bigint,
parameters map<string,string>,
start_time_local bigint
)
STORED AS PARQUET
LOCATION 's3://bucket/path/to/folder/containing_files/'
tblproperties ("parquet.compression" = "GZIP")
列表中倒数第二
我有一个装满 .gz.parquet 文件的 S3 存储桶。我想让它们在 Athena 中可用。为此,我在 Athena 中创建了一个指向 s3 存储桶的 table:
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 数据类型的良好文档您可以使用 AWS Glue 爬虫从您的 Parquet 文件中自动派生架构。
定义 AWS Glue 爬虫:https://docs.aws.amazon.com/glue/latest/dg/add-crawler.html
映射被声明为 map<string,string>
(对于字符串到字符串的映射,其他类型也是可能的),在您的情况下,整个 table DDL 将是:
CREATE EXTERNAL TABLE user_db.table (
pan_id bigint,
dev_id bigint,
parameters map<string,string>,
start_time_local bigint
)
STORED AS PARQUET
LOCATION 's3://bucket/path/to/folder/containing_files/'
tblproperties ("parquet.compression" = "GZIP")
列表中倒数第二