You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Tyler Hobbs (JIRA)" <ji...@apache.org> on 2014/04/26 00:15:17 UTC

[jira] [Commented] (CASSANDRA-7095) Cqlsh reads floats and doubles with added non-trivial precision

    [ https://issues.apache.org/jira/browse/CASSANDRA-7095?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13981695#comment-13981695 ] 

Tyler Hobbs commented on CASSANDRA-7095:
----------------------------------------

This is a quirk of python's float precision formatting, it seems:
{noformat}
>>> "%.*g" % (16, 2.0002)
'2.0002'
>>> "%.*g" % (17, 2.0002)
'2.0002'
>>> "%.*g" % (18, 2.0002)
'2.00019999999999998'
{noformat}
At some point, if you keep increasing the precision, it does weird things.

> Cqlsh reads floats and doubles with added non-trivial precision
> ---------------------------------------------------------------
>
>                 Key: CASSANDRA-7095
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-7095
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Tools
>         Environment: Ubuntu 12.04.3
> Python 2.7.3
>            Reporter: Andrew Spitzer
>            Assignee: Mikhail Stepura
>
> I found that on Cqlsh v. 4.1.1 and Cassandra 2.0.6.28 when I inserted value into float or double column, "select" returned a slightly different value
> If cqlsh returns with only a low level precision, this does not show:
> {code}
> cqlsh> create KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor':1};
> cqlsh> use test ;
> cqlsh:test> create table testing (a int PRIMARY KEY , b float);
> cqlsh:test> INSERT INTO testing (a, b ) VALUES (  1, 2.0002);
> cqlsh:test> select * FROM testing ;
>  a | b
> ---+--------
>  1 | 2.0002
> {code}
> But if precision is increased, for example, 20 digits:
> {code}
> cqlsh> SELECT * FROM test.testing ;
>  a | b
> ---+-----------------------
>  1 | 2.0002000331878662109
> {code}
> Using sstable2json, one sees that this issue is with cqlsh, the actual data is  the value inserted:
> {code}
> sstable2json /var/lib/cassandra/data/test/testing/test-testing-jb-1-Data.db 
> [
> {"key": "00000001","columns": [["","",1398459775180000], ["b","2.0002",1398459775180000]]}
> ]
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)