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

Environment

ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
cassandra-driver-3.2.1
[cqlsh 5.0.1 | Cassandra 3.11.1 | CQL spec 3.4.4 | Native protocol v4]

Pull Requests

None

Activity

Show:
Fixed

Details

Assignee

Reporter

Reproduced in

Fix versions

Affects versions

Priority

Created January 6, 2018 at 3:28 AM
Updated January 24, 2018 at 7:09 PM
Resolved January 24, 2018 at 7:09 PM