问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/23573599/astyanax-cassandra-double-type-precision