在不同键空间上创建Cassandra物化视图失败-未配置表
我创建了两个键空间:在不同键空间上创建Cassandra物化视图失败-未配置表,cassandra,Cassandra,我创建了两个键空间: CREATE KEYSPACE test1 WITH replication = {'class': 'SimpleStrategy', 'replicatio n_factor': '3'} CREATE KEYSPACE test2 WITH repli
CREATE KEYSPACE test1 WITH replication = {'class': 'SimpleStrategy', 'replicatio n_factor': '3'}
CREATE KEYSPACE test2 WITH replication = {'class': 'SimpleStrategy', 'replicatio n_factor': '3'}
在test1上创建表用户
在test2上创建物化视图
获取错误:
InvalidRequest:来自服务器的错误:代码=2200[无效查询]
message=“未配置的表用户”
效果很好 根据卡桑德拉的记录,这应该是可行的 要在非当前键空间的键空间中创建物化视图,请将键空间名称放在物化视图名称的前面,后跟句点 在Cassandra 3.0和3.9上进行了检查-同一版本 我使用cqlsh从cassandra节点连接 test1.0用户可从test2访问:
cqlsh:test2> select * from test1.users;
user_name | id | password
-----------+----+----------
(0行)
我错过了什么吗
谢谢
另外,表和物化视图必须在同一个键空间中。
您误解了文档 要在非当前键空间的键空间中创建物化视图,请将键空间名称放在物化视图名称前面,后跟句点 如果当前键空间与表的键空间不同,则必须将表的键空间名称放在物化视图名称前面,后跟句点。
物化视图将在表的键空间中创建,感谢您的快速响应。有了这个特性,MV就可以有不同的复制行为,这可能是件好事。
CREATE MATERIALIZED VIEW test2.user_by_id AS
SELECT * FROM test1.users where id is not null and user_name is not null
PRIMARY KEY (id,user_name);
CREATE MATERIALIZED VIEW test1.user_by_id AS
SELECT * FROM test1.users where id is not null and user_name is not null
PRIMARY KEY (id,user_name);
cqlsh:test2> select * from test1.users;
user_name | id | password
-----------+----+----------