我从s3存储桶中获得了如下格式的数据。
"2010-9","aws cloud","{"id":1,"name":"test"}"
"2010-9","aws cloud1","{"id":2,"name":"test2"}"我想复制数据库中的数据,如下所示。
表格
year | env | desc
2010-9 | aws cloud |{"id":1,"name":"test"}
2010-9 | aws cloud1 |{"id":2,"name":"test2"}我已经写了这个命令,但是不能工作。你能帮帮我吗?
copy table
from 's3://bucketname/manifest' credentials 'aws_access_key_id=xx;aws_secret_access_key=xxx'
delimiter ','
IGNOREHEADER 1
REMOVEQUOTES
IGNOREBLANKLINES
manifest;发布于 2020-04-26 06:25:41
您就快到了-您只需要转义第三个字段(desc)中的双引号。根据
If double-quotes are used to enclose fields, then a double-quote
appearing inside a field must be escaped by preceding it with
another double quote. For example: "aaa","b""bb","ccc"这是根据rfc-4180 - https://www.ietf.org/rfc/rfc4180.txt
我还将json加载到Redshift的文本字段中,然后使用json函数解析该字段。效果很好。
https://stackoverflow.com/questions/61412437
复制相似问题