UNLOAD Redshift: append

♀尐吖头ヾ 提交于 2021-02-11 07:56:23

问题


I'd like to UNLOAD data from Redshift table into already existing S3 folder, in a similar way of what happens in Spark with the write option "append" (so creating new files in the target folder if this already exists).

I'm aware of the ALLOWOVERWRITE option but this deletes the already existing folder.

Is it something supported in Redshift? If not, what approach is recommended? (it would be anyway a desired feature I believe...)


回答1:


One solution that could solve the issue is to attach another unique suffix after the folder e.g.

unload ('select * from my_table') 
to 's3://mybucket/first_folder/unique_prefix_' iam_role 
'arn:aws:iam::0123456789012:role/MyRedshiftRole'; 

If you add unique_prefix_ after the first folder level, all your new files, will start with your unique_prefix_ during the unload operation, therefore you don't need any ALLOWOVERWRITE. The only issue of this approach is that if you unloaded data change, you might have mix schema for your unloaded data.



来源:https://stackoverflow.com/questions/61594463/unload-redshift-append

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!