cassandra cqlsh数据格式问题

问题描述 投票:2回答:1

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

CQLSH问题:当我描述列族时,我看到列名正确显示但是when I do a select on the table我看到所有列名都以'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驱动程序的任何缺少的依赖项。这还没有解决问题。

任何帮助都非常感谢。我花了很多时间来弄清楚修复,并希望我能在这里得到一些答案:)

python cassandra cqlsh column-family
1个回答
0
投票

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

解决方案:使用Cassandra发送的/usr/bin/cqlsh将您的Cassandra节点与命令连接:

$ /usr/bin/cqlsh <ip>

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

© www.soinside.com 2019 - 2024. All rights reserved.