I want to copy an array from jsonb field to a PostgreSQL array column:
CREATE TABLE survey_results (
id integer NOT NULL,
areas text[],
raw jsonb DEFAULT '{}'::jsonb
);
INSERT INTO survey_results (id, raw)
VALUES (1, '{"areas": ["test", "test2"]}');
UPDATE survey_results SET areas = CAST(raw#>>'{areas}' AS text[]);
This returns me?
ERROR: malformed array literal: "["test", "test2"]" Detail: "[" must introduce explicitly-specified array dimensions.
How can I fix that?