【问题标题】:getting error while using IN operator in cassandra 3.4在 cassandra 3.4 中使用 IN 运算符时出错
【发布时间】:2018-09-13 19:40:47
【问题描述】:

Cassandra 版本:- [cqlsh 5.0.1 | Cassandra 3.0.9 | CQL spec 3.4.0 | Native protocol v4]

我的表结构

CREATE TABLE test (
id1 text,
id2 text,
id3 text,
id4 text,
clinet_starttime timestamp,
avail_endtime timestamp,
starttime timestamp,
client_endtime timestamp,
code int,
status text,
total_time double,
PRIMARY KEY (id1, id2, id3, id4, client_starttime)
) WITH CLUSTERING ORDER BY (id2 ASC, id3 ASC, id4 ASC, client_starttime ASC)
AND 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', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
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_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';

以下查询对我有用

SELECT * FROM test WHERE client_starttime<1522832400000 AND client_starttime>1522831800000 AND id1='data1' AND id2='data2' AND id3='data3' AND id4 IN ('data5','data6','data7') ALLOW FILTERING;

但是当我使用starttimeavail_endTime 而不是client_starttime 进行查询时

SELECT * FROM test WHERE starttime<1522832400000 AND avail_endTime>1522831800000 AND id1='data1' AND id2='data2' AND id3='data3' AND id4 IN ('data5','data6','data7') ALLOW FILTERING;

出现以下错误

InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot restrict clustering columns by IN relations when a collection is selected by the query"

如果我不使用IN 运算符,如果我使用= 运算符,那么它工作正常

SELECT * FROM test WHERE starttime<1522832400000 AND avail_endTime>1522831800000 AND id1='data1' AND id2='data2' AND id3='data3' AND id4 = 'data5'ALLOW FILTERING;

但我想同时检索data5, data6 and data7 的数据。

【问题讨论】:

  • 我不建议使用ALLOW FILTERING - 虽然它适用于小数据集,但它会在大表上失败。

标签: cassandra cassandra-3.0


【解决方案1】:

这是一个已知的 Cassandra 错误:CASSANDRA-12654 - 它已经修复,但仅在尚未定义发布日期的 4.0 版中可用。

【讨论】:

    猜你喜欢
    • 2016-11-03
    • 2015-01-22
    • 2016-08-01
    • 2018-04-15
    • 2018-07-30
    • 2015-05-05
    • 2017-02-02
    • 1970-01-01
    • 2014-06-07
    相关资源
    最近更新 更多