Support reading decimals in scientific notation with positive exponent
Description
When reading back decimals from Cassandra in scientific format the following error is given: /home/xxxx/.rvm/gems/ruby-2.4.1/gems/cassandra-driver-3.2.1/lib/cassandra/future.rb:631:in `get': All attempted hosts failed: 127.0.0.1 (Cassandra::Errors::IOError: no implicit conversion of nil into String) (Cassandra::Errors::NoHostsAvailable) from /home/timg/.rvm/gems/ruby-2.4.1/gems/cassandra-driver-3.2.1/lib/cassandra/future.rb:396:in `get' from debugging.rb:29:in `do_query' from debugging.rb:38:in `<main>'
The section of code where it actually falls over is: def read_decimal(len = bytesize) in cql_byte_buffer
The exact line is: fraction_string << number_string[number_string.length - size, number_string.length]
Steps to reproduce:
- Create a table with a decimal column in it:
CREATE TABLE broken ( my_id text PRIMARY KEY, bad decimal );
- Insert a record with a scientific format number in it:
INSERT INTO broken (my_id, bad) VALUES ('invalid2', 1.0E+7);
Try to read this number back with the driver:
session.execute_async("SELECT bad FROM broken") future.on_success do |rows| .... end future.join
Note that if you insert the same number, but not in scientific format then you can successfully read it back. So it seems Cassandra itself is also behaving slightly strangely
When reading back decimals from Cassandra in scientific format the following error is given:
/home/xxxx/.rvm/gems/ruby-2.4.1/gems/cassandra-driver-3.2.1/lib/cassandra/future.rb:631:in `get': All attempted hosts failed: 127.0.0.1 (Cassandra::Errors::IOError: no implicit conversion of nil into String) (Cassandra::Errors::NoHostsAvailable)
from /home/timg/.rvm/gems/ruby-2.4.1/gems/cassandra-driver-3.2.1/lib/cassandra/future.rb:396:in `get'
from debugging.rb:29:in `do_query'
from debugging.rb:38:in `<main>'
The section of code where it actually falls over is:
def read_decimal(len = bytesize) in cql_byte_buffer
The exact line is:
fraction_string <<
number_string[number_string.length - size, number_string.length]
Steps to reproduce:
- Create a table with a decimal column in it:
CREATE TABLE broken (
my_id text PRIMARY KEY,
bad decimal
);
- Insert a record with a scientific format number in it:
INSERT INTO broken (my_id, bad) VALUES ('invalid2', 1.0E+7);
Try to read this number back with the driver:
session.execute_async("SELECT bad FROM broken")
future.on_success do |rows|
....
end
future.join
Note that if you insert the same number, but not in scientific format then you can successfully read it back. So it seems Cassandra itself is also behaving slightly strangely