简体   繁体   中英

How to unload csv file type when unload is compressed with gzip?

Hi I have this query that will Unload data from redshift to S3 that will output as csv file and compressed with gzip. Supposedly, if I extract the gzip it will give me the csv file but instead it extract as "file".

The image attached is the output of partitioned year which is 2018. I was expecting that the unzip file would be on csv format since I specified it in the query but instead it gives me a "file" as file type. gzip

Query:

UNLOAD ($$ SELECT *, (date_part("year", last_updated))::text as year FROM table WHERE date_part("year", last_updated) <= (date_part("year", CURRENT_DATE)-1) $$)
TO 's3://'
IAM_ROLE  ''
PARTITION BY (year) 
CSV DELIMITER AS  '|'
GZIP
PARALLEL FALSE
ALLOWOVERWRITE
MAXFILESIZE AS 100 MB;

A little more on what you are getting would be helpful but I think I see the issue. You specified a partition column which will split the out output files by this value (multiple files, one per year) but did add the INCLUDE option to partition that will tell UNLOAD to keep the partition values in the output files as well. Since you have only one column, year and this is being used for the partitioned file names you get empty files.

Without more info it will be hard to do better than this interpretation of you commands.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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