次のスキーマを持つ複合列ファミリーがあります
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>'
私が間違っているのは何ですか?それともバグですか?
よろしく、マドゥ