0
votes

Can you please let me know - is it possible to append dynamic YYYYMMDDHH24MISS

during unload data from redshift table - Table.YYYYMMDDHH24MISS.csv

unload statement:

unload ('select * from New_records')
to 's3://mybucket/unload/sysdate' 
iam_role 'arn:aws:iam::0123456789012:role/MyRedshiftRole';
1
You can't achieve this directly using Redshift commands but you could use some external tool such as python or powershell to generate the unload command, including dynamically creating the filename based on current date and time, and then execute that command on Redshift (e.g. using an ODBC connection). - Nathan Griffiths

1 Answers

-2
votes

No. Dynamically populating variables in unload script is not yet supported.

There have been similar requirements, like, to append timestamp, change filename etc during runtime. That can be achieved by getting the result set as generated by the unload statement and then modifying the results with a script.

This question had similar requirements (dynamically change attributes etc).