我有一个具有以下架构的复合列族
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>'
我做错了什么?或者它是一个错误?
问候,马杜