cassandra: ~.cqlshrc does not work for float_preci

2019-07-11 20:14发布

问题:

I created file in .cassandra directory and changed the cqlshrc file.

[ui] float_precision = 10

But that did not work. I am using ccm with Cassandra in Ubuntu.

回答1:

Inside your cqlshrc file, you need to designate your [ui] section and define your float_precision on separate lines. In your example, it shows that you are defining them on the same line.

Here you can see that I have my cqlshrc file defined as you do. When querying a float in cqlsh, it defaults to a precision of 5.

aploetz@dockingBay94:~$ cat .cassandra/cqlshrc
[ui] float_precision = 10

aploetz@dockingBay94:~$ cqlsh -u aploetz -p aploetz
Connected to VaporTrails at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.0.1 | CQL spec 3.3.1 | Native protocol v4]
Use HELP for help.
aploetz@cqlsh> use stackoverflow ;
aploetz@cqlsh:stackoverflow> SELECT * FROm floattest;

 id                                   | value
--------------------------------------+---------
 d79fee54-e67b-4178-bfc9-155ffe6a9372 | 5.82375

(1 rows)

But when I put them on separate lines, it properly enforces my desired float precision:

aploetz@dockingBay94:~$ cat .cassandra/cqlshrc
[ui]
float_precision = 10

aploetz@dockingBay94:~$ cqlsh -u aploetz -p aploetz
Connected to VaporTrails at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.0.1 | CQL spec 3.3.1 | Native protocol v4]
Use HELP for help.
aploetz@cqlsh> use stackoverflow ;
aploetz@cqlsh:stackoverflow> SELECT * FROm floattest;

 id                                   | value
--------------------------------------+--------------
 d79fee54-e67b-4178-bfc9-155ffe6a9372 | 5.8237495422

(1 rows)