aiguy
aiguy

Reputation: 691

Cassandra mathematical operations within a single row

Suppose there is a table holding some points with columns id (primary key), and coordinates x, y, z

Suppose I wanted to add an extra column calculating say average value of x, y and z for every point. Is that possible through cqlsh? Or would I have to select all the rows, modify them, and write them back?

Upvotes: 1

Views: 72

Answers (1)

Jeff Jirsa
Jeff Jirsa

Reputation: 4426

To physically write them as a new column, you'd need to query them, do the average, and then write it back explicitly.

However, you could also calculate the average on the fly - if you want to do that, the concepts you're looking for are:

User Defined Functions or User Defined Aggregates

Upvotes: 3

Related Questions