Redshift缺乏对阵列的支持如何应对 [英] How deal with Redshift lack of support for Arrays
本文介绍了Redshift缺乏对阵列的支持如何应对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Redshift不支持数组,但是我的源数据库有Redshift中需要的几个Array列.
Redshift does not support Arrays, however my source database has several Array columns that I need in Redshift.
在尝试将其迁移到Redshift时应如何处理?
How should this field type be handled when trying to migrate it into Redshift?
推荐答案
虽然Redshift在PostgreSQL感知中不支持数组,但它提供了一些您可能需要查看的JSON函数:
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
您可以将数组插入varchar
列:
create temporary table _test (col1 varchar(20));
insert into _test values ('[1,2,3]');
然后使用json_extract_array_element_text()
将产生:
db=# select json_extract_array_element_text(col1, 2) from _test;
json_extract_array_element_text
---------------------------------
3
(1 row)
这篇关于Redshift缺乏对阵列的支持如何应对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文