Reputation: 2084
Let's say I have table with 2 columns
primary key
: id - type varchar
and non-primary-key
: data - type text
Data column consist only of json
values for example like:
{
"name":"John",
"age":30
}
I know that i can not alter this column to map
type but maybe i can add new map
column with values from data
column or maybe you have some other idea?
What can i do about it ? I want to get map
column in this table with values from data
Upvotes: 1
Views: 489
Reputation: 104
You might want to make use of the CQL COPY command to export all your data to a CSV file.
Then alter your table and create a new column of type map
.
Convert the exported data to another file containing UPDATE
statements where you only update the newly created column with values converted from JSON to a map
. For conversion use a tool or language of your choice (be it bash, python, perl or whatever).
BTW be aware, that with map
you specify what data type is your map's key and what data type is your map's value. So you will most probably be limited to use strings only if you want to be generic, i.e. a map<text, text>
. Consider whether this is appropriate for your use case.
Upvotes: 1