Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

InternalError_: Spectrum Scan Error. S3 to Redshift copy command

I am trying to copy some data from S3 bucket to redshift table by using the COPY command. The format of the file is PARQUET. When I run the execute the COPY command query, I get InternalError_: Spectrum Scan Error.

Error

This is the first time I tried copying from a parquet file.

Please help me if there is a solution for this. I am using boto3 in python.

like image 245
bazinga Avatar asked Mar 29 '20 21:03

bazinga


People also ask

What is Redshift Spectrum scan error?

Spectrum scan error are usually caused by two things. a) column mismatch between source and destination e.g. if u are copying data from S3 to redshift then, the columns of parquet are not in order with those present in redshift tables.

How do I transfer data from S3 to Redshift using Python?

Attach the policy to the IAM role; at this stage, Redshift will be able to read data in the target bucket. Create a Redshift cluster. Create a Redshift table whose structure is the same as the original CSV file structure. Copy data from the CSV files stored in the S3 bucket to the Redshift table.


2 Answers

This generally happens for below reasons:

  1. If there is a mismatch in number of columns between table and file.
  2. If the Column type of your file schema is incompatible with your target table column type.

Try going into the error logs. You might find partial log in cloud watch. From the screen shot you have uplaoded, you can also find a query number you have run.

Got to aws redshift query editor and run below query to get the full log:

select message 
from svl_s3log 
where query = '<<your query number>>'
order by query,segment,slice; 

Hope this helps !

like image 131
Akhil Ghatiki Avatar answered Sep 20 '22 14:09

Akhil Ghatiki


This error usually indicates some problem with compatibility of data in your file and redshift tables. you can get more insights about error in table 'SVL_S3LOG'. In my case it was because file had some invalid utf8 characters.

like image 27
Kamal Vashist Avatar answered Sep 16 '22 14:09

Kamal Vashist