2

我有一个可操作的 cassandra 集群,在单个数据中心模式下安装了 apache Cassandra 3.7 的 tarball。

CQLSH 问题: 当我描述列族时,我看到列名正确显示,但是当我在表上进行选择时,我看到所有列名都以“u”为前缀:

cassandra@cqlsh> describe cassandra_test.employee; 
CREATE TABLE cassandra_test.employee (
    employee_id text PRIMARY KEY,         
    employee_grp_cd text, 
    employee mbrp_id text ) 
WITH bloom filter_fp_chance = 0.01         
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} 
    AND comment = " 
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max threshold': '32', emin_threshold': '4'} 
    AND compression = fichunk_length_in_kb1: '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'l 
    AND crc_check_chance = 1.0 
    AND dclocal_read_repair_chance = 0.1 
    AND default_time_to_live = 0 
    AND gc_grace_seconds = 864000 
    AND max_index_interval = 2048 
    AND memtable_flush_period_in ms = 0 
    AND min_indexinterval = 128 
    AND read_repair_chance = 0.0 
    AND speculative_retry = '99PERCENTILE'; 
cassandra@cqlsh> select * from cassandra_test.employee; 

u'employee_id' | u'employee_grp_cd' | u'employee_mbrp_id' 
---------------+--------------------+----------------------

(0 rows) 
Failed to format value u'employee_id' : 'unicode' object has no attribute 'formatter' 
Failed to format value u'employee_grp_cd' : 'unicode' object has no attribute 'formatter' 1 more decoding errors suppressed. cassandra@cqlsh> 0 
1 more decoding errors suppressed.

当我插入记录并进行选择时,插入的也以'u'为前缀。我做了几次尝试,每个相关链接似乎都指向 python 问题。

我当前的 python 版本:Python 2.7.11 :: Anaconda 4.0.0(64 位),我做了一个pip install cassandra-driver为 Cassandra 驱动程序安装任何缺少的依赖项。这并没有解决问题。

非常感谢任何帮助。我花了很多时间来解决这个问题,并希望我能在这里得到一些答案:)

4

1 回答 1

0

可能的原因:您的 cqlsh 路径/usr/local/bin/cqlsh可能是由 pip 安装的。(使用命令检查哪个 cqlsh $ which cqlsh

解决方案:使用 Cassandra/usr/bin/cqlsh提供的命令连接您的 Cassandra 节点:

$ /usr/bin/cqlsh <ip>

然后查询检查结果,前缀'u'会消失。

于 2019-05-01T02:15:57.503 回答