AWS Data Pipeline RedShift "delimiter not found" 错误
AWS Data Pipeline RedShift "delimiter not found" error
我正在研究数据管道。在其中一个步骤中,来自 S3 的 CSV 被 RedShift DataNode 使用。我的 RedShift table 有 78 列。检查:
SELECT COUNT(*) FROM information_schema.columns WHERE table_name = 'my_table';
失败后 RedshiftCopyActivity 'stl_load_errors' table 显示第 1 行的 "Delimiter not found" (1214) 错误,对于位置 0 上的列命名空间(这是第二列,varchar(255)) . 使用的 CSV 行如下所示:
0,my.namespace.string,2119652,458031,S,60,2015-05-02,2015-05-02 14:51:02,2015-05-02 14:51:14.0,1,Counter,1,Counter 01,91,Chaymae,0,,,,227817,1,Dine In,5788,2015-05-02 14:51:02,2015-05-02 14:51:27,17.45,0.00,0.00,17.45,,91,Chaymae,0,0.00,12,M,A,-1,13,F,0,0,2,2.50,F,1094055,Coleslaw Md Upt,8,Sonstige,900,Sides,901,Sides,0.00,0.00,0,,,0.0000,0,0,,,0.00,0.0000,0.0000,0,,,0.00,0.0000,,1,Woche Counter,127,Coleslaw Md Upt,2,2.50
经过简单替换(“,”到“\n”)后,我有 78 行,所以看起来数据应该匹配......我一直坚持下去。也许有人知道如何找到有关错误的更多信息或查看解决方案?
编辑
查询:
select d.query, substring(d.filename,14,20),
d.line_number as line,
substring(d.value,1,16) as value,
substring(le.err_reason,1,48) as err_reason
from stl_loaderror_detail d, stl_load_errors le
where d.query = le.query
and d.query = pg_last_copy_id();
结果为 0 行。
我弄明白了,也许对其他人有用:
事实上有两个问题。
- 我在 redshift table 中的第一个字段是
INT IDENTITY(1,1)
类型,在 CSV 中我有 0
值。从 CSV 中删除第一列后,即使没有指定的列映射,也可以毫无问题地复制所有内容 if...
DELIMITER ','
commandOption 已添加到 S3ToRedshiftCopyActivity 以强制使用逗号。没有它,RedShift 将命名空间 (my.namespace.string) 中的点识别为分隔符。
您需要添加 FORMAT AS JSON 's3://yourbucketname/aJsonPathFile.txt'。 AWS 尚未提及这一点。请注意,这仅在您的数据采用 json 形式(如
时有效)
{'attr1': 'val1', 'attr2': 'val2'} {'attr1': 'val1', 'attr2': 'val2'}
{'attr1': 'val1', 'attr2': 'val2'} {'attr1': 'val1', 'attr2': 'val2'}
我正在研究数据管道。在其中一个步骤中,来自 S3 的 CSV 被 RedShift DataNode 使用。我的 RedShift table 有 78 列。检查:
SELECT COUNT(*) FROM information_schema.columns WHERE table_name = 'my_table';
失败后 RedshiftCopyActivity 'stl_load_errors' table 显示第 1 行的 "Delimiter not found" (1214) 错误,对于位置 0 上的列命名空间(这是第二列,varchar(255)) . 使用的 CSV 行如下所示:
0,my.namespace.string,2119652,458031,S,60,2015-05-02,2015-05-02 14:51:02,2015-05-02 14:51:14.0,1,Counter,1,Counter 01,91,Chaymae,0,,,,227817,1,Dine In,5788,2015-05-02 14:51:02,2015-05-02 14:51:27,17.45,0.00,0.00,17.45,,91,Chaymae,0,0.00,12,M,A,-1,13,F,0,0,2,2.50,F,1094055,Coleslaw Md Upt,8,Sonstige,900,Sides,901,Sides,0.00,0.00,0,,,0.0000,0,0,,,0.00,0.0000,0.0000,0,,,0.00,0.0000,,1,Woche Counter,127,Coleslaw Md Upt,2,2.50
经过简单替换(“,”到“\n”)后,我有 78 行,所以看起来数据应该匹配......我一直坚持下去。也许有人知道如何找到有关错误的更多信息或查看解决方案?
编辑
查询:
select d.query, substring(d.filename,14,20),
d.line_number as line,
substring(d.value,1,16) as value,
substring(le.err_reason,1,48) as err_reason
from stl_loaderror_detail d, stl_load_errors le
where d.query = le.query
and d.query = pg_last_copy_id();
结果为 0 行。
我弄明白了,也许对其他人有用:
事实上有两个问题。
- 我在 redshift table 中的第一个字段是
INT IDENTITY(1,1)
类型,在 CSV 中我有0
值。从 CSV 中删除第一列后,即使没有指定的列映射,也可以毫无问题地复制所有内容 if... DELIMITER ','
commandOption 已添加到 S3ToRedshiftCopyActivity 以强制使用逗号。没有它,RedShift 将命名空间 (my.namespace.string) 中的点识别为分隔符。
您需要添加 FORMAT AS JSON 's3://yourbucketname/aJsonPathFile.txt'。 AWS 尚未提及这一点。请注意,这仅在您的数据采用 json 形式(如
时有效){'attr1': 'val1', 'attr2': 'val2'} {'attr1': 'val1', 'attr2': 'val2'} {'attr1': 'val1', 'attr2': 'val2'} {'attr1': 'val1', 'attr2': 'val2'}