Mariana
Mariana

Reputation: 359

Parse and Transform JSON Array of strings in sql

I have a table that has a column that contains an array of strings, example ["Emily", "Anna"], I need to parse this array into 2 columns. Is there a way to do this in sql?

I have tried OPENJSON but this function doesn't work in databricks

Upvotes: 1

Views: 253

Answers (1)

S-Man
S-Man

Reputation: 23726

Just use the array element indexes:

demo:db<>fiddle

SELECT
    mycolumn[1] AS first_value,
    mycolumn[2] AS second_value
FROM
    mytable

Upvotes: 2

Related Questions