如何在Cassandra中存储6位精度的双精度数字/浮点数字/十进制数? [英] How to store 6 digit precision double/float/decimal number in cassandra?

查看:111
本文介绍了如何在Cassandra中存储6位精度的双精度数字/浮点数字/十进制数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在cassandra表中存储数据帧的某些字符串.我尝试使用定义为float/double/decimal的cassandra表列.

I am trying to store some strings of a dataframe in cassandra table. I tried with cassandra table columns defining as float/double/decimal.

但是每种类型仅存储2个精度,即8.00005作为8.00存储69.345和69.34一样,cassandra表出了什么问题?为什么它不保存所有精度数字.如何解决这个问题?让我知道是否需要有关该问题的更多信息.

But every type only storing 2 precision , i.e. 8.00005 as stored as 8.00 69.345 as 69.34 , what is wrong with cassandra table? Why it is not holding all precision digits. How fix this issue ? Let me know if needed any more information of the problem.

推荐答案

此问题似乎与cqlsh的精度设置有关.cassandra正确存储了值,但是当您通过cqlsh查询时,精度点设置会将其四舍五入.

This issue seeme to be with the precision settings for cqlsh. The cassandra is storing the values properly , but when you query it through cqlsh , the precision point settings are rounding it off.

了解有关精度点的cqlshrc选项的更多信息:

Read about the cqlshrc options about the precision points for more information : cqlshrc

以下是默认的cqlshrc设置:

The following are the default cqlshrc settings :

;; The number of digits displayed after the decimal point for single and double 
precision numbers
;; (note that increasing this to large numbers can result in unusual values)
;float_precision = 5

检查以下示例:

create table temp(id int , "val" float ,PRIMARY KEY (id));

insert into temp(id,val) values(1,1.234567);

在设置float_precision之前选择:

Select before setting float_precision :

select * from temp;

 id | val
----+---------
 1 | 1.23457

将float_precision设置为6后选择:

Select after setting float_precision to 6 :

select * from temp;

 id | val
----+----------
 1 | 1.234567

这篇关于如何在Cassandra中存储6位精度的双精度数字/浮点数字/十进制数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆