Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Astyanax Cassandra Double type precision

I'm trying to get a Double value from a Cassandra table with a double type column. I've created the table in CQL3 syntax:

CREATE TABLE data_double (
    datetime timestamp,
    value double,
    primary key (datetime)
    );

I've inserted a row:

INSERT INTO data_double (datetime,  value) VALUES ('111111111', 123.456);  

When I do:

SELECT * from data_double;

I get that the value is 123.46

Why is the value rounded?

Thanks

like image 673
Guy Wald Avatar asked May 09 '14 20:05

Guy Wald


1 Answers

The cqlsh utility by default will only display 5 digits of precision for floating point numbers.

You can increase this by creating a cqlshrc file with contents like the following:

[ui]
float_precision = 10

The cqlsh docs page provides more details on the available options.

Update: The location of the cqlshrc file changed at some point in Cassandra. The new default location is ~/.cassandra/cqlshrc. You can also use a file in a different location with the --cqlshrc command-line option.

like image 78
BrianC Avatar answered Oct 16 '22 13:10

BrianC