我有一个复合列系列,其中包含以下架构
CREATE TABLE employees (
name varchar,
month int,
date int,
salary decimal,
PRIMARY KEY(name,month,date)
);
从CQL执行时这很好用。
#INSERT INTO employees (name,month,date,salary) VALUES ('joe',1,1,1000);
然而,当尝试使用Ruby Clinet插入时,这是失败的。
client = Cassandra.new('keyspace_name', '127.0.0.1:9160')
colkey = Cassandra::Composite.new([4].pack('N'), [5].pack('N'), 'salary')
client.insert(:employees, 'nick', {colkey=> [2000].pack("D")}) - This is failing
client.insert(:employees, 'nick', {colkey=> "2000"}) - This works fine
这是错误:
CassandraThrift::InvalidRequestException: CassandraThrift::InvalidRequestException
from /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.16.0/vendor/0.8/gen-rb/cassandra.rb:252:in `recv_batch_mutate'
from /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.16.0/vendor/0.8/gen-rb/cassandra.rb:243:in `batch_mutate'
from /usr/local/lib/ruby/gems/1.9.1/gems/thrift_client-0.8.2/lib/thrift_client/abstract_thrift_client.rb:148:in `handled_proxy'
from /usr/local/lib/ruby/gems/1.9.1/gems/thrift_client-0.8.2/lib/thrift_client/abstract_thrift_client.rb:51:in `batch_mutate'
from /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.16.0/lib/cassandra/protocol.rb:7:in `_mutate'
from /usr/local/lib/ruby/gems/1.9.1/gems/cassandra-0.16.0/lib/cassandra/cassandra.rb:463:in `insert'
from (irb):41
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我做错了什么?还是一个bug?
的问候, 马杜