任何提示为何我从该主题中得到错误。在下面,我粘贴了所有步骤以重现该错误。
我发现有人遇到同样的问题,我尝试了提出的解决方案,但我确实遇到了同样的问题。
我尝试按照Materialised view error in Cassandra创建表all_orders并遵循@halfer解决方案,但遇到了完全相同的错误消息。
整个日志:
C:\Program Files\DataStax Community\apache-cassandra\bin>set JAVA_HOME=C:\Program Files\Java\jre1.8.0_171
C:\Program Files\DataStax Community\apache-cassandra\bin>cqlsh
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 2.2.3 | CQL spec 3.3.1 | Native protocol v4]
Use HELP for help.
WARNING: pyreadline dependency missing. Install to enable tab completion.
cqlsh> CREATE KEYSPACE IF NOT EXISTS sample WITH replication = {'class':'SimpleStrategy', 'replication_factor':1};
cqlsh> use sample;
cqlsh:sample> CREATE TABLE IF NOT EXISTS sample.hotels (
... id UUID,
... name varchar,
... address varchar,
... state varchar,
... zip varchar,
... primary key(id)
... );
cqlsh:sample>
cqlsh:sample> CREATE TABLE IF NOT EXISTS sample.hotels_by_letter (
... first_letter varchar,
... hotel_name varchar,
... hotel_id UUID,
... address varchar,
... state varchar,
... zip varchar,
... primary key((first_letter), hotel_name, hotel_id)
... );
cqlsh:sample> CREATE MATERIALIZED VIEW sample.hotels_by_state AS
... SELECT id, name, address, state, zip FROM hotels
... WHERE state IS NOT NULL AND id IS NOT NULL AND name IS NOT NULL
... PRIMARY KEY ((state), id)
... WITH CLUSTERING ORDER BY (name DESC)
... ;
SyntaxException: <ErrorMessage code=2000 [Syntax error in CQL query] message="line 1:7 no viable alternative at input 'MATERIALIZED' ([CREATE] MATERIALIZED...)">
***添加了
我尝试了https://www.datastax.com/dev/blog/new-in-cassandra-3-0-materialized-views中提供的确切示例,但遇到了同样的问题(证据如下)。
cqlsh:sample> CREATE TABLE scores
... (
... user TEXT,
... game TEXT,
... year INT,
... month INT,
... day INT,
... score INT,
... PRIMARY KEY (user, game, year, month, day)
... );
cqlsh:sample> CREATE MATERIALIZED VIEW alltimehigh AS
... SELECT user FROM scores
... WHERE game IS NOT NULL AND score IS NOT NULL AND user IS NOT NULL AND year IS NOT NULL AND month IS NOT NULL AND day IS NOT NULL
... PRIMARY KEY (game, score, user, year, month, day)
... WITH CLUSTERING ORDER BY (score desc);
SyntaxException: <ErrorMessage code=2000 [Syntax error in CQL query] message="line 1:7 no viable alternative at input 'MATERIALIZED' ([CREATE] MATERIALIZED...)">
cqlsh:sample>
答案 0 :(得分:2)
我不认为这是Cassandra 2.X中的选项。我以为这是3.X规范(我们跳到3.11,效果还不错)。