How can I use UNLOAD with PARALLEL OFF and not have 000 appended to the filename?

0

Subject says it all. Is there a way to NOT have 000 appended to the filename given in the UNLOAD command when PARALLEL is set to OFF? I've tried EXTENSION but this seems to append the extension given after the 000 is appended to the filename.

Thanks

已提問 7 個月前檢視次數 694 次
2 個答案
0
已接受的答案

Hello,

Before I commence with explanation, I would like to mention that currently the "000" suffix is part of UNLOAD command architecture and there are no parameters available to avoid the "000" suffix, and here is why..

Amazon Redshift unloads the data in parallel from all nodes in cluster to provide maximum network throughput and fast UNLOAD operation. If PARALLEL is set to OFF or FALSE, UNLOAD writes to one or more data files serially, with data sorted according to the ORDER BY clause, if one is used. The maximum size for a data file is 6.2 GB. So, for example, if you unload 13.4 GB of data, UNLOAD creates the following three files.

s3://mybucket/key000    6.2 GB
s3://mybucket/key001    6.2 GB
s3://mybucket/key002    1.0 GB

Thus, the "000" number format is appended to the provided file path to ensure there is no redundancy in file names unloaded by Redshift for large resultsets. Here, as the resultset size of SELECT query in UNLOAD command cannot be predicted beforehand, there is no UNLOAD command parameter provided to control the appending of "000" suffix.

I hope you found this information helpful. Thank you !!

AWS
支援工程師
已回答 7 個月前
  • I get the purpose of it. I think the frustration I have with this is to supplant already existing exports using UNLOAD. For processes going forward we just have to set expectations that 000 will be part of the filename (as long as we're sure the file size will never exceed 6.2 GB) . We can use the EXTENSION parameter so that the filename still meets standard naming conventions.

0

Hello,

Since there is no native options from Amazon Redshift, I have tried to find some workarounds for you. You can ignore the appended part while reading the file or you can rename the file using S3 mv cli command like below:

 aws s3 mv s3://<S3-bucket>/<prefix>/file.000 s3://<S3-bucket>/<prefix>/file

You could also use lambda or shell/powershell script to do a renaming process in your use case to avoid this issue.

I hope it will help and have a nice day!

AWS
已回答 7 個月前
  • Thanks. Yes unfortunately we have to use a Glue job to rename the file. Honestly, for go-forward, if we know the file size will never exceed 6.2GB we could bake it into the requirements to expect 000 as part of the filename. It would mean using the EXTENTION parameter so that the extension gets applied after the 000.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南