Cassandra表创建失败,错误请求:输入不匹配

时间:2014-02-18 18:12:14

标签: cassandra cql cql3 cqlsh

我创建了一个Cassandra键空间跟踪器:

CREATE KEYSPACE tracker WITH replication = {
  'class': 'SimpleStrategy',
  'replication_factor': '3'
};

然后我可以在这个密钥空间中成功创建一个表:

cqlsh:tracker> CREATE TABLE tracker.click_windows (
           ...   visitor_id text,
           ...   created_at timeuuid,
           ...   click_id text,
           ...   ended_at timeuuid,
           ...   expires_at timeuuid,
           ...   processed_at timeuuid,
           ...   window_size int,
           ...   PRIMARY KEY (visitor_id, created_at)
           ... ) WITH CLUSTERING ORDER BY (created_at DESC) AND
           ...   bloom_filter_fp_chance=0.010000 AND
           ...   caching='KEYS_ONLY' AND
           ...   comment='' AND
           ...   dclocal_read_repair_chance=0.000000 AND
           ...   gc_grace_seconds=864000 AND
           ...   read_repair_chance=0.100000 AND
           ...   replicate_on_write='true' AND
           ...   populate_io_cache_on_flush='false' AND
           ...   compaction={'class': 'SizeTieredCompactionStrategy'} AND
           ...   compression={'sstable_compression': 'SnappyCompressor'};

但是当我去添加下一个表/列系列时,我收到一个错误:

cqlsh> CREATE TABLE tracker.clicks (
   ...   id text PRIMARY KEY,
   ...   created_at timeuuid,
   ...   data map
   ... ) WITH
   ...   bloom_filter_fp_chance=0.010000 AND
   ...   caching='ALL' AND
   ...   comment='' AND
   ...   dclocal_read_repair_chance=0.000000 AND
   ...   gc_grace_seconds=864000 AND
   ...   read_repair_chance=0.100000 AND
   ...   replicate_on_write='true' AND
   ...   populate_io_cache_on_flush='false' AND
   ...   compaction={'class': 'SizeTieredCompactionStrategy'} AND
   ...   compression={'sstable_compression': 'SnappyCompressor'};
Bad Request: line 5:0 mismatched input ')' expecting '<'

我发现有些迹象表明这可能是CQL版本问题,但是当我用--cql3启动cqlsh时,这仍然会发生。我没有看到任何明显的关于这两个是如此不同的一个工作而另一个不工作。我还有其他不工作的东西,比如

cqlsh> CREATE TABLE tracker.session_hits (
   ...   session_id timeuuid,
   ...   hit_id timeuuid,
   ...   click_id text,
   ...   created_at timeuuid,
   ...   data map,
   ...   visitor_id text,
   ...   window_ids list,
   ...   PRIMARY KEY (session_id, hit_id)
   ... ) WITH CLUSTERING ORDER BY (hit_id DESC) AND
   ...   bloom_filter_fp_chance=0.010000 AND
   ...   caching='KEYS_ONLY' AND
   ...   comment='' AND
   ...   dclocal_read_repair_chance=0.000000 AND
   ...   gc_grace_seconds=864000 AND
   ...   read_repair_chance=0.100000 AND
   ...   replicate_on_write='true' AND
   ...   populate_io_cache_on_flush='false' AND
   ...   compaction={'class': 'SizeTieredCompactionStrategy'} AND
   ...   compression={'sstable_compression': 'SnappyCompressor'};
Bad Request: line 8:17 mismatched input ',' expecting '<'

建议?

1 个答案:

答案 0 :(得分:7)

您必须参数化您的集合(地图/列表)定义

http://cassandra.apache.org/doc/cql3/CQL.html#types

<collection-type> ::= list '<' <native-type> '>'
                    | set  '<' <native-type> '>'
                    | map  '<' <native-type> ',' <native-type> '>'