spring-data-cassandra icon indicating copy to clipboard operation
spring-data-cassandra copied to clipboard

Support materialized views [DATACASS-383]

Open spring-projects-issues opened this issue 8 years ago • 5 comments
trafficstars

Mark Paluch opened DATACASS-383 and commented

See http://www.datastax.com/dev/blog/new-in-cassandra-3-0-materialized-views


5 votes, 9 watchers

spring-projects-issues avatar Jan 09 '17 15:01 spring-projects-issues

Andrew commented

To speed up the process, just wanted to suggest an example of what we implemented in our project.

Define additional views on table entities:

@Table("user")
@MaterializedViews({
  @MaterializedView(name="user_by_email", primaryKeyColumns = {
        @PrimaryKeyColumn(value = "email", type = PrimaryKeyType.PARTITIONED),
        @PrimaryKeyColumn(value = "id")
    })
})

Use a query:

@Table("user")
@MaterializedViews({
  @MaterializedView(name="user_by_email",
      query="SELECT * FROM user WHERE email IS NOT NULL AND id IS NOT NULL",
      primaryKeyColumns = {
        @PrimaryKeyColumn(value = "email", type = PrimaryKeyType.PARTITIONED),
        @PrimaryKeyColumn(value = "id")
    })
})

Plus added schema specs and generation/drop extending CassandraPersistentEntitySchemaCreator and CassandraSessionFactoryBean. Works fine so far.

spring-projects-issues avatar Jun 17 '17 10:06 spring-projects-issues

Kamil commented

Guys, are there any plans to support it?

spring-projects-issues avatar Apr 17 '18 13:04 spring-projects-issues

Mark Paluch commented

It makes sense to start out with CQL generation and view descriptors in the first place. I'm not entirely sold on annotation-based schema creation. The query part allows more than just NOT NULL predicates. Stating queries that way is error-prone and functionality can be only verified when using schema creation.

Using views requires our CassandraTemplate methods to also accept a table name

spring-projects-issues avatar Apr 17 '18 15:04 spring-projects-issues

Nate McCall commented

We have retro-actively marked Materialized Views as experimental. In order to keep users from hitting any of the (numerous) issues, I am asking that you avoid creating any implementations here until we can iron out the functionality. http://mail-archives.apache.org/mod_mbox/cassandra-user/201710.mbox/%[email protected]%3E

spring-projects-issues avatar Jul 17 '18 02:07 spring-projects-issues

Mark Paluch commented

Thanks for the heads up

spring-projects-issues avatar Jul 17 '18 06:07 spring-projects-issues