0

Bazı CSV günlük verilerini S3'ten bir Redshift Cluster'a almak için bir AWS Veri Aktarımı kurdum.AWS Veri Aktarım verileri S3'ten Redshift'e veri kopyalama verileri

Benim Redshift veritabanı tablosu aşağıdaki yapıya sahiptir:

"172.20.2.224", "boş", "boş", "2016: İşte

CREATE TABLE access_log 
(
    id bigint identity(1, 1), 
    host character varying(64), 
    cf_host character varying(64), 
    xff_host character varying(64), 
    event_time timestamp, 
    method character varying(16), 
    url text, 
    response_code integer, 
    referer text, 
    user_agent text, 
    device_id character varying(40), 
    primary key(id) 
) 
sortkey(id); 

benim CSV günlük verilerinin bir özdür -03-16 00:01:28 "," GET ","/"," 302 "," null "," null " " 172.20.2.224 "," null "," null "," 2016-03- 16 00:01:33 "," GET ","/"," 200 "," null "," null " " 172.20.2.224 "," null "," null "," 2016-03-16 00: 11:28 "," GET ","/"," 302 "," null "," null " " 172.20.2.224 "," null "," null "," 2016-03-16 00:11:33 "," GET ","/"," 200 "," null "," null " "172.20.2.224", "null", "null", "2016-03-16 00:21:28", "GET", "/", "302", "null", "null" "172.20 .2.224 "," null "," null "," 2016-03-16 00:21:33 "," GET ","/"," 200 "," null "," null "

SQLWorkbenchJ

copy access_log 
from 's3://mylogrepo' 
credentials 
'aws_access_key_id=myaccesskey;aws_secret_access_key=myaccesskeysecret' 
DELIMITER ',' 
REMOVEQUOTES 
TIMEFORMAT 'YYYY-MM-DD HH:MI:SS' 

Ama Redshift kopyaladığınızda aktivite aşağıdaki hatayı alıyorum çalışır: aşağıdaki kopya kullanırsanız komut her şey iyi çalışır Benim ilginç bulduğum hata yığın izleme sonra bu satır

[Amazon](500310) Invalid operation: cannot set an identity column to a value; 

geçerli:

private.com.amazonaws.services.datapipeline.redshift.QueryStatementException: Exception Amazon Invalid operation: cannot set an identity column to a value; while executing START TRANSACTION; INSERT INTO public.access_log SELECT s.* FROM staging s LEFT JOIN public.access_log t ON s."id" = t."id" WHERE t."id" IS NULL; COMMIT; at private.com.amazonaws.services.datapipeline.redshift.RedshiftQueryStatement.(RedshiftQueryStatement.java:43) at private.com.amazonaws.services.datapipeline.redshift.RedshiftQueryStatementFactory.newQueryStatement(RedshiftQueryStatementFactory.java:9) at ... private.com.amazonaws.services.datapipeline.redshift.SqlHelper.prepareStatement(SqlHelper.java:84) at $TaskRunner.run(HeartbeatingTaskRunner.java:34) ... 1 more Caused by: java.sql.SQLException: Amazon Invalid operation: cannot set an identity column to a value; at com.amazon.redshift.client.messages.inbound.ErrorResponse.toErrorException(Unknown Source)

CSV verilerimdeki IP'nin sütun kimliği olarak yorumlanması mümkün mü?

Teşekkür ederiz!

cevap

0

Geçersiz bir s3 sütun eşlemeniz olduğundan şüpheleniyorum. Sütun eşlemenizi paylaşabilir misiniz?

+1

Device_id bilgilerini CSV verilerime aktarmayı unuttum. Bu nedenle, kopya komutu, CSV verilerinden 9 sütunu 10 sütun tablosuna eşlemeyi denedi. CSV verilerime device_id bilgisi ekledikten sonra işe yarayacak gibi görünüyor. Teşekkür ederim! –