我正在使用COPY命令将数据从CSV文件导入Amazon Redshift并出现错误:
COPY table1 FROM 's3://cucket1/table1.csv'
credentials 'aws_access_key_id=aaaa;aws_secret_access_key=aaaa'
IGNOREHEADER 1
csv
NULL AS '\N'
timeformat 'auto';
错误:装入表'table1'失败。查看“ stl_load_errors”系统表以了解详细信息。
我的csv文件如下:
"id","name","created_at","updated_at"
"1","2","NULL","NULL"
"2","1","NULL","NULL"
"6","1","NULL","NULL"
"87","1","NULL","NULL"
当我从csv文件中删除NULL值时,COPY命令运行正常。
如何在redshift COPY命令中处理NULL值?enter code here
答案 0 :(得分:2)
看起来您的NULL
的格式为"NULL"
。这应该起作用:
COPY table1 FROM 's3://cucket1/table1.csv'
credentials 'aws_access_key_id=aaaa;aws_secret_access_key=aaaa'
IGNOREHEADER 1
csv
NULL AS 'NULL'
timeformat 'auto';
也可以查看stl_load_errors
可以使您更好地了解问题所在。
您尝试过select * from stl_load_errors order by starttime desc limit 100;
吗?该查询应为您提供有关无法加载的数据的所有详细信息。我怀疑您的情况是"NULL"
未被解析为TIMESTAMP
类型。