【发布时间】:2017-04-07 12:11:57
【问题描述】:
我创建了 2 个键空间:
CREATE KEYSPACE test1 WITH replication = {'class': 'SimpleStrategy', 'replicatio n_factor': '3'}
CREATE KEYSPACE test2 WITH replication = {'class': 'SimpleStrategy', 'replicatio n_factor': '3'}
在 test1 上创建表用户
CREATE TABLE test1.users (
user_name varchar ,
password varchar,
id varchar,
primary key(user_name,id)
);
在 test2 上创建物化视图
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);
得到错误:
InvalidRequest:来自服务器的错误:code=2200 [无效查询] message="未配置的表用户"
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);
效果很好。
根据 Cassandra 文档,这应该可以工作。
https://docs.datastax.com/en/cql/3.3/cql/cql_reference/refCreateMV.html
"要在当前键空间以外的键空间中创建物化视图,请将键空间名称放在物化视图名称前面,后跟句点"
在 Cassandra 3.0 和 3.9 上检查过——同样的问题。
我使用 cqlsh 从 cassandra 节点连接。
test1.users 可以从 test2 访问:
cqlsh:test2> select * from test1.users;
user_name | id | password
-----------+----+----------
(0 行)
我错过了什么吗?
谢谢
阿隆
【问题讨论】:
标签: cassandra