在redshift

时间:2017-09-11 19:51:24

标签: json serialization deserialization amazon-redshift avro

我正在使用Avro对我的数据进行序列化和反序列化。我将序列化数据保存到S3中。我试图将s3中的数据读取到红移,但无法读取它。

尝试使用Avro格式

S3记录 -

{"breachId":"0eb3130c-241a-461b-99ab-4910301fa012","metricName":"SIC_FAST_TRACK","regionId":"1","marketplace":"1","glProductGroup":"14","snapshotDate":"2017-09-11","breachDate":"2017-08-14","year":2017,"baseWeekNumber":29,"weekNumber":29}

Redshift结束时的命令 -

COPY test FROM 's3://test/test.avro'
WITH credentials 'aws_iam_role=arn:aws:iam::355548666665:role/MY_IAM_ROLE'
FORMAT AS AVRO 'auto';

红移时出错 - [

Amazon](500310) Invalid operation: Invalid AVRO file
Details: 
 -----------------------------------------------
  error:  Invalid AVRO file
  code:      8001
  context:   Cannot init avro reader from s3 file Incorrect Avro container file magic number 
  query:     1210354
  location:  avropath_request.cpp:432
  process:   query24_642 [pid=113227]
  -----------------------------------------------;

尝试使用JSON格式

S3记录 -

{"breachId":"31847d29-e542-4468-b32e-33cfb3a191b2","metricName":"SIC_FAST_TRACK","regionId":"1","marketplace":"1","glProductGroup":"14","snapshotDate":"2017-09-11","breachDate":"2017-08-14","year":2017,"baseWeekNumber":29,"weekNumber":29}

在redshift复制命令 -

COPY test FROM 's3://test/test.json'
WITH credentials 'aws_iam_role=arn:aws:iam::355548666665:role/MY_IAM_ROLE'
FORMAT AS JSON 'auto'

红移输出 -

1 row with partial data uploaded in the table. 

我无法理解该怎么做。有人可以在这帮忙吗?

0 个答案:

没有答案