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



patrickjp93 avatar image
patrickjp93 asked Erick Ramirez answered

Cassandra InvalidQueryException on Materialized View — PRIMARY KEY part found in SET part

Aren't Materialized Views supposed to provide a Read-optimizing layer over top of the ALLOW FILTERING mechanism? Because the following seems like it fits the Cassandra criteria, but I'm getting exceptions complaining that an update statement is affecting a Primary Key, which should only be on tables, not Mat Views.

I've made a table with a 1-column Primary Key

    .withPartitionKey(PKEY, DataTypes.TEXT)
    .withColumn(C1, DataTypes.TEXT)
    .withColumn(C2, DataTypes.TEXT)
    .withColumn(C3, DataTypes.TEXT)
    .columns(PKEY, C1, C2, C3)
PreparedStatement ps = session.prepare(
    update(NAME).setColumn(C2, QueryBuilder.bindMarker())

"ps" is throwing the exception. By my reading of the Cassandra Driver Spec, this is incorrect. Can someone point shed some light on this?

Java driver 4.11.0

native protocol 1.5.0

datastax cassandra version 4.1.10

materialized views
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered

The examples you posted are too vague for me to work out what you want to achieve. It would be great if you could update the original question body with a description in plain English of the base table and what the materialised view is supposed to be.

It doesn't make sense why you're using the same columns in the primary key so you need to provide more background information.

Please provide the full error message + full stack trace too. Cheers!

10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.