简体   繁体   English

Redshift / S3-将Redshift表的内容作为JSON复制到S3吗?

[英]Redshift/S3 - Copy the contents of a Redshift table to S3 as JSON?

It's straightforward to copy JSON data on S3 into a Redshift table using the standard Redshift COPY command. 使用标准Redshift COPY命令将S3上的JSON数据复制到Redshift表中非常简单。

However, I'm also looking for the inverse operation: to copy the data contained within an existing Redshift table to JSON that is stored in S3, so that a subsequent Redshift COPY command can recreate the Redshift table exactly as it was originally. 但是,我也在寻找相反的操作:将现有Redshift表中包含的数据复制到S3中存储的JSON,以便随后的Redshift COPY命令可以完全按照原始方式重新创建Redshift表。

I know about the Redshift UNLOAD commnd, but it doesn't seem to offer any option to store the data in S3 directly in JSON format. 我知道Redshift UNLOAD命令,但似乎没有提供任何选择以JSON格式直接在S3中存储数据。

I know that I can write per-table utilities to parse and reformat the output of UNLOAD for each table, but I'm looking for a generic solution which allows me to do this Redshift-to-S3-JSON extract on any specified Redshift table. 我知道我可以编写每表实用程序来解析和重新格式化每个表的UNLOAD输出,但是我正在寻找一种通用解决方案,该解决方案允许我对任何指定的Redshift表执行Redshift-to-S3-JSON提取。

I couldn't find any existing utilities that will do this. 我找不到任何可以执行此操作的实用程序。 Did I miss something? 我错过了什么?

Thank you in advance. 先感谢您。

我认为唯一的方法是卸载CSV并编写一个简单的lambda函数,以CSV标头作为键并将每行的值作为值,将输入CSV转换为JSON。

There is no built in way to do this yet. 尚无内置方法来执行此操作。 So you might have to hack your query with some hardcoding : 因此,您可能必须使用一些硬编码来破解您的查询:

https://sikandar89dubey.wordpress.com/2015/12/23/how-to-dump-data-from-redshift-to-json/ https://sikandar89dubey.wordpress.com/2015/12/23/how-to-dump-data-from-redshift-to-json/

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

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