【问题标题】:cassandra cqlsh data format issuecassandra cqlsh 数据格式问题
【发布时间】:2017-07-26 15:59:07
【问题描述】:

我有一个可操作的 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 驱动程序缺少的任何依赖项。这并没有解决问题。

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

【问题讨论】:

  • 欢迎来到 StackOverflow!请不要发布指向仅包含文本的图像/屏幕截图的链接。将终端活动直接复制/粘贴到您的问题中。 stackoverflow.com/help/how-to-ask
  • 这不会发生在我用那个 Python 运行时运行 cqlsh 的情况下。这有点令人困惑,因为人们通常会在 Python cqlsh 在这种情况下不会启动。你能试试cqlsh --debug -e "select * from cassandra_test.employee;"吗?
  • 转录屏幕截图中的代码,这样如果屏幕截图丢失,我们就会遇到代码问题。看起来像unicode

标签: python cassandra cqlsh column-family


【解决方案1】:

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

解决方案:使用 Cassandra 发货 /usr/bin/cqlsh 连接您的 Cassandra 节点,使用以下命令:

$ /usr/bin/cqlsh <ip>

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

【讨论】:

    猜你喜欢
    • 2020-10-05
    • 2020-07-20
    • 2015-06-08
    • 2023-03-30
    • 2013-10-06
    • 2019-04-05
    • 2013-10-29
    • 2019-06-29
    • 2017-10-13
    相关资源
    最近更新 更多