Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How deal with Redshift lack of support for Arrays

Redshift does not support Arrays, however my source database has several Array columns that I need in Redshift.

How should this field type be handled when trying to migrate it into Redshift?

like image 707
BestPractices Avatar asked Jul 16 '16 16:07

BestPractices


People also ask

Does Redshift support array data type?

As mentioned in the previous section, Amazon Redshift does not support array types or functions. Though, Redshift uses PostgreSQL, but they yet to provide support to arrays. You can check unsupported features in the official documentation. Best part is, Amazon Redshift provides support for JSON functions.

Can Redshift store arrays?

Understand what the SUPER data type is in Amazon Redshift – The SUPER data type is an Amazon Redshift data type that enables the storage of schemaless arrays and structures that contain Amazon Redshift scalars and possibly nested arrays and structures.

What are the limitations of Amazon Redshift?

Amazon Redshift doesn't support tables with column-level privileges for cross-database queries. Amazon Redshift doesn't support concurrency scaling for the queries that read data from other databases. Amazon Redshift doesn't support query catalog objects on AWS Glue or federated databases.

Does AWS Redshift support unstructured data?

Unstructured data – Data in Amazon Redshift must be structured by a defined schema, rather than supporting arbitrary schema structure for each row. If your data is unstructured, you can perform extract, transform, and load (ETL) on Amazon EMR to get the data ready for loading into Amazon Redshift.


1 Answers

While Redshift does not support arrays in the PostgreSQL-sense, it provides some JSON functions you might want to have a look at: http://docs.aws.amazon.com/redshift/latest/dg/json-functions.html

You can insert arrays into varchar columns:

create temporary table _test (col1 varchar(20));
insert into _test values ('[1,2,3]');

Then using json_extract_array_element_text() would yield:

db=# select json_extract_array_element_text(col1, 2) from _test;
 json_extract_array_element_text
---------------------------------
 3
(1 row)
like image 134
moertel Avatar answered Sep 28 '22 16:09

moertel