CQL 查询中的语法错误] message="行 1:7 输入 'MATERIALIZED' 没有可行的替代方案([CREATE] MATERIALIZED

Syntax error in CQL query] message="line 1:7 no viable alternative at input 'MATERIALIZED' ([CREATE] MATERIALIZED

我从主题中得到错误的任何线索。下面我粘贴了所有步骤以重现错误。

我发现有人面临同样的问题,我尝试了建议的解决方案,但我确实遇到了完全相同的问题。

我尝试通过创建 table all_orders 来遵循 Materialised view error in Cassandra 并遵循@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>

我不认为这是 Cassandra 中的一个选项 2.X。我认为这是一个 3.X 规范(我们跳到了 3.11,它工作得很好)。