Difference between UPDATE and INSERT in Cassandra?

后端 未结 4 1731
情歌与酒
情歌与酒 2020-12-28 12:06

What is the difference between UPDATE and INSERT when executing CQL against Cassandra?

It looks like there used to be no difference, but no

4条回答
  •  盖世英雄少女心
    2020-12-28 12:43

    Regarding the subtle difference highlighted by billbaird (I'm unable to comment on that post directly) where a row created by an update operation will be deleted if all non-key fields are null:

    That is expected behavior and not a bug based on the bug report at https://issues.apache.org/jira/browse/CASSANDRA-11805 (which was closed as "Not A Problem")

    I ran into this myself when using Spring Data for the first time. I was using the save(T entity) method of a repository, but no row was being created. it turned out Spring Data was using an UPDATE because it determined that the object wasn't 'new' (not sure that test for 'isNew' makes sense here), and I happened to be testing with entities that only had the key fields set.

    For this Spring Data case, the Cassandra-specific repository interfaces do provide an insert method that appear to consistently use an INSERT if that behavior is desired instead (though Spring's documentation doesn't document these details sufficiently either).

提交回复
热议问题