简体   繁体   English

将 Parquet 文件加载到 Redshift

[英]Load Parquet files into Redshift

I have a bunch of Parquet files on S3, i want to load them into redshift in most optimal way.我在 S3 上有一堆 Parquet 文件,我想以最佳方式将它们加载到 redshift 中。

Each file is split into multiple chunks......what is the most optimal way to load data from S3 into Redshift?每个文件被分成多个块......将数据从 S3 加载到 Redshift 的最佳方法是什么?

Also, how do you create the target table definition in Redshift?另外,如何在 Redshift 中创建目标表定义? Is there a way to infer schema from Parquet and create table programatically?有没有办法从 Parquet 推断模式并以编程方式创建表? I believe there is a way to do this using Redshift spectrum, but i want to know if this can be done in scripting.我相信有一种方法可以使用 Redshift 频谱来做到这一点,但我想知道这是否可以在脚本中完成。

Appreciate your help!感谢你的帮助!

I am considering all AWS tools such as Glue, Lambda etc to do this the most optimal way(in terms of performance, security and cost).我正在考虑使用所有 AWS 工具(例如 Glue、Lambda 等)来以最佳方式(在性能、安全性和成本方面)执行此操作。

The Amazon Redshift COPY command can natively load Parquet files by using the parameter: Amazon Redshift COPY 命令可以使用以下参数本机加载 Parquet 文件:

FORMAT AS PARQUET

See: Amazon Redshift Can Now COPY from Parquet and ORC File Formats请参阅: Amazon Redshift 现在可以从 Parquet 和 ORC 文件格式复制

The table must be pre-created;该表必须预先创建; it cannot be created automatically.它不能自动创建。

Also note from COPY from Columnar Data Formats - Amazon Redshift :另请注意来自列式数据格式 - Amazon Redshift 的 COPY

COPY inserts values into the target table's columns in the same order as the columns occur in the columnar data files. COPY 将值插入到目标表的列中,其顺序与列在列式数据文件中出现的顺序相同 The number of columns in the target table and the number of columns in the data file must match.目标表中的列数和数据文件中的列数必须匹配。

use parquet-tools from GitHub to dissect the file :使用来自 GitHub 的parquet-tools来剖析文件:

parquet-tool schema <filename> #will dump the schema w/datatypes
parquet-tool head <filename> #will dump the first 5 data structures

Use the jsonpaths file to specify mappings使用jsonpaths文件指定映射

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM