I have two tables A and B.
How to implement the following logic?
If a doesn't exists in A: insert a into A and insert b into B. [NOTE: the insertions of a and b must be "Cassandra batch" style.]
If a exist in A, don't insert b into B.
Bringing together the Apache Cassandra experts from the community and DataStax.
Want to learn? Have a question? Want to share your expertise? You are in the right place!
Not sure where to begin? Getting Started
I have two tables A and B.
How to implement the following logic?
If a doesn't exists in A: insert a into A and insert b into B. [NOTE: the insertions of a and b must be "Cassandra batch" style.]
If a exist in A, don't insert b into B.
Lightweight transactions only provide isolation on a per-table basis.
It is not possible to do a conditional write (INSERT, UPDATE, DELETE) to table B based on the existence of a partition in table A. You can only specify a condition based on table B if you're writing to table B.
You will need to implement that logic in your application. Cheers!
[UPDATE] In the case where you want to do a conditional BATCH
update, writing to multiple tables is not supported. Conditional batch updates can only contain statements for one table.
Again, the solution is to implement it in your application. Be aware that a read-before-write is expensive so use it sparingly.
thanks Erick. Sorry that my origin quesion was wrong. Now I refined the description.
Any insights would be much appreciated!
5 People are following this question.
DataStax Enterprise is powered by the best distribution of Apache Cassandra ™
© 2022 DataStax, Titan, and TitanDB are registered trademarks of DataStax, Inc. and its subsidiaries in the United States and/or other countries.
Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries.
Privacy Policy Terms of Use