Updating a cassandra field using string concatenation

I am trying to update an existing row column in a cassandra table.

For example, I want to add a domain id before the username.

Below is a table

id, username
1, agaikwad
2, xyz

      

I want to write cql to update the above table to reflect the following

id, username
1, homeoffice\\agaikwad
2, homeoffice\\xyz

      

Here is what I have tried

update users set username = 'homeoffice\\' + username where id = <id>

      

+3


source to share


1 answer


This is not allowed in C * because it implicitly requires reads before writing, which is bad practice with C * (and an expensive proposition in a distributed system). For this behavior, you can save this field as a list of strings, lists support the add operation, and you can concatenate from the application side.



+5


source







All Articles