从Redshift卸载到S3以CSV格式不会创建.csv文件。

huangapple go评论85阅读模式
英文:

Unloading from Redshift to S3 in CSV format doesn't create the .csv file

问题

当我从Redshift卸载到S3以CSV格式时,然后当我前往S3中指定的路径时,没有任何.csv文件。我看到的唯一文件是清单文件和000文件。

命令如下:

UNLOAD('select distinct * from mytable')
to 's3://my-bucket/data/myfile'
iam_role 'xxxxxxxxxxxxxxxxxxxxxx'
header
CSV DELIMITER AS '|'
manifest 
allowoverwrite
parallel off 

查询运行正常,当我前往S3路径时,我看到如下和类型列中的连字符(-):

myfile000
myfilemanifest

难道不应该还有一个.csv文件吗?

谢谢。

我不知道如何继续处理这个问题。

英文:

When I unload from Redshift to S3 in CSV format, then when I go the specified path in s3 there isn't any .csv file. The only files I see are the manifest and the 000 file.

The command is the below

UNLOAD('select distinct * from mytable')
to 's3://my-bucket/data/myfile'
iam_role 'xxxxxxxxxxxxxxxxxxxxxx'
header
CSV DELIMITER AS '|'
manifest 
allowoverwrite
parallel off 

The query runs fine and when I go the S3 path I see the below and a hyphen (-) in the type column:

myfile000
myfilemanifest

Shouldn't there also be a .csv file?

Thanks.

I don't know how to proceed on this.

答案1

得分: 1

这是Redshift处理文件的方式,它将000附加到文件名后,但如果你更关心在文件名后附加.csv扩展名,你可以通过向UNLOAD命令添加EXTENSION 'extension-name'选项来实现。

https://docs.aws.amazon.com/redshift/latest/dg/r_UNLOAD.html

所以在你的情况下,可以这样做:

UNLOAD
(
'
select distinct * from mytable
'
)
TO 's3://my-bucket/data/myfile'
iam_role 'xxxxxxxxxxxxxxxxxxxxxx'
header
CSV DELIMITER AS '|'
manifest 
allowoverwrite
parallel off 
EXTENSION '.csv'
英文:

It's a way how Redshift handles files where it appends 000 to the filename, though if your concern is more to get a .csv extension appened to the file name you can do so by adding the EXTENSION 'extension-name' option to the UNLOAD command

https://docs.aws.amazon.com/redshift/latest/dg/r_UNLOAD.html

So in your case it would be

UNLOAD
(
'
select distinct * from mytable
'
)

to 's3://my-bucket/data/myfile'
iam_role 'xxxxxxxxxxxxxxxxxxxxxx'
header
CSV DELIMITER AS '|'
manifest 
allowoverwrite
parallel off 
EXTENSION '.csv'

huangapple
  • 本文由 发表于 2023年3月8日 18:24:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/75671818.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定