I have a cassandra table who has a composite primary key: (school_id, student_id)
. Let's say that I want to delete all the records in this table that belong to one school. Using cassandra driver, I tried to bind only the school_id
like:
val query = QueryBuilder.delete().all().from(session.loggedKeyspace, "mytable")
.where(QueryBuilder.eq("school_id", QueryBuilder.bindMarker())
.bind("school_1")
session.execute(query)
I get an error saying that:
com.datastax.driver.core.exceptions.InvalidQueryException: Missing mandatory PRIMARY KEY part student_id
I could have thousands of students in one school. Do I have to query the table first to get all distinct student_id
s and then use this delete statement?