Cassandra 4.x - duplicate all values in one column to another

53 Views Asked by At

I need to copy the value of one column to another column in Cassandra.

The table has recently been altered to include the new column fieldC, so all values are shown as null. FieldC needs to contain the same value as fieldB (which may also contain null).

The primary key is PRIMARY KEY (fieldA);

E.g. select * from my_table;

fieldA | fieldB | fieldC
-------+--------+-------
test_1 | test_1 | null
test_2 | null   | null
... 
(another 2 million or more records)
...

Is there a way to do this in cqlsh using an UPDATE command (setting the value of a non-PK field to the value of another, non-PK field), or other similar approach, without using COPY?

1

There are 1 best solutions below

0
Madhavan On

Nope. You would have to do it at the app layer (or) use some creative DSBulk unload -> awk/sed magic -> DSBulk load back.