Created
September 15, 2014 06:59
-
-
Save laughingman7743/ed5e708979f9ea6e9326 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
column1, | |
column2, | |
column3, | |
column4, | |
column5 | |
from ( | |
select | |
'"column1"' column1, | |
'"column2"' column2, | |
'"column3"' column3, | |
'"column4"' column4, | |
'"column5"' column5, | |
0 as sort_order | |
union all | |
select | |
'"' || coalesce(cast(column1 as text), '') || '"', | |
'"' || coalesce(cast(column2 as text), '') || '"', | |
'"' || coalesce(cast(column3 as text), '') || '"', | |
'"' || coalesce(cast(column4 as text), '') || '"', | |
'"' || coalesce(cast(column5 as text), '') || '"', | |
1 | |
from my_table | |
) | |
order by sort_order; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unload (' | |
select | |
column1, | |
column2, | |
column3, | |
column4, | |
column5 | |
from ( | |
select | |
\'"column1"\' column1, | |
\'"column2"\' column2, | |
\'"column3"\' column3, | |
\'"column4"\' column4, | |
\'"column5"\' column5, | |
0 as sort_order | |
union all | |
select | |
\'"\' || coalesce(cast(column1 as text), \'\') || \'"\', | |
\'"\' || coalesce(cast(column2 as text), \'\') || \'"\', | |
\'"\' || coalesce(cast(column3 as text), \'\') || \'"\', | |
\'"\' || coalesce(cast(column4 as text), \'\') || \'"\', | |
\'"\' || coalesce(cast(column5 as text), \'\') || \'"\', | |
1 | |
from my_table | |
) | |
order by sort_order; | |
') | |
TO 's3://object_path_prefix' | |
credentials 'aws_access_credentials' | |
gzip delimiter AS ',' escape allowoverwrite manifest parallel off; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment