[ https://issues.apache.org/jira/browse/CASSANDRA-11947?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16064226#comment-16064226 ]
ZhaoYang edited comment on CASSANDRA-11947 at 6/27/17 4:11 AM: --------------------------------------------------------------- How about trying following schema? basically the same query as you want. {code} cqlsh:jira> CREATE MATERIALIZED VIEW analytics_ww AS ... SELECT * FROM analytics ... WHERE date IS NOT NULL AND resourceId IS NOT NULL AND country IS NOT NULL AND country = 'WW' ... PRIMARY KEY (resourceId, date, country); {code} The original idea to stop `collapsing` data in MV (part of base primary key columns in view) is to protect user from unexpected tombstones.. But in this case, if the `missing primary key in the view` is guarded by a filter condition, it should be safe. If your use case can be done via above example, I suggest won'tfix. was (Author: jasonstack): How about trying following schema? basically the same query as you want. {code} cqlsh:jira> CREATE MATERIALIZED VIEW analytics_ww AS ... SELECT * FROM analytics ... WHERE date IS NOT NULL AND resourceId IS NOT NULL AND country IS NOT NULL AND country = 'WW' ... PRIMARY KEY (resourceId, date, country); {code} The original idea to stop `collapsing` data in MV (part of base primary key columns in view) is to protect user from tombstones.. I think in this case, if the `missing primary key in the view` is guarded by a filter condition, it's safe. If your use case can be done via above example, I suggest won'tfix. > Ability to create a Materialized View without primary key column that has '=' > relation > -------------------------------------------------------------------------------------- > > Key: CASSANDRA-11947 > URL: https://issues.apache.org/jira/browse/CASSANDRA-11947 > Project: Cassandra > Issue Type: Improvement > Reporter: Nimi Wariboko Jr. > > I have a use case where I'd like to create a materialized view where one of > the columns is filtered on a '=' relation and the primary key for that > materialized view doesn't include that column. > Example: > {code} > CREATE TABLE analytics ( > resourceId text, > country text, > date timestamp, > clicks int, > PRIMARY KEY(resourceId, date, country) > ); > CREATE MATERIALIZED VIEW analytics_ww AS > SELECT * FROM analytics > WHERE country = 'WW' > PRIMARY KEY (resourceId, date); > {code} > This way I can have a table filtered on a high cardinality column, and I > don't also have to specify that column, even though I already know thats the > only value in the view. -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org