【发布时间】:2017-05-12 23:30:19
【问题描述】:
Cassandra 中的变量有什么特别之处吗?我有一个包含 varint 列的表,但以下 select 语句不起作用:
select * from hourly_average where application_id = 3 and partner_id = 1 and location_id = 1 and device_id = 10003;
application_id、partner_id 和 location_id 是变量。如果我将它们转换为常规整数,则 select 语句可以正常工作。当它们是 varint 时,它返回 0 个结果,即使有很多结果与这些值匹配。
更新:添加表定义:
CREATE TABLE myschema.hourly_average (
application_id varint,
partner_id varint,
location_id varint,
device_id int,
day date,
hour int,
average float,
count int,
max float,
min float,
PRIMARY KEY ((application_id, partner_id, location_id, device_id), day, hour)
) WITH CLUSTERING ORDER BY (day DESC, hour DESC)
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 *的一些输出
application_id | partner_id | location_id | device_id | day | hour | average | count | max | min
----------------+------------+-------------+-----------+------------+------+------------+-------+------+------
3 | 1 | 1 | 20004 | 2016-12-01 | 2 | 0 | 1 | 0 | 0
3 | 1 | 1 | 20004 | 2016-12-01 | 1 | 0 | 2 | 0 | 0
3 | 1 | 1 | 20004 | 2016-12-01 | 0 | 0 | 2 | 0 | 0
3 | 1 | 1 | 20004 | 2016-11-30 | 23 | 0 | 2 | 0 | 0
3 | 1 | 1 | 10003 | 2016-12-01 | 2 | 1290.80017 | 75 | 1553 | 820
3 | 1 | 1 | 10003 | 2016-12-01 | 1 | 888.19165 | 120 | 957 | 830
3 | 1 | 1 | 10003 | 2016-12-01 | 0 | 991.09167 | 120 | 1062 | 896
版本是 dsc-cassandra 3.0.9。
注意:
这似乎与最初是 int 的列有关,而我更改了表并使其成为 varint。如果我创建一个只有一列 int 类型的全新表,添加一些数据,然后将其更改为 varint 类型,则会出现同样的问题。将列类型从 int 更改为 varint 是否存在某种错误?
【问题讨论】:
-
你能发布你的表定义吗?您是否使用任何二级索引?你在哪个版本?确实很奇怪...我刚刚尝试了您的示例,并且效果很好,所以我需要看看您的桌子到底长什么样。
-
添加了更多细节。
-
注意,它似乎与最初是 int 的列有关,而我更改了表并使其成为 varint。如果我创建一个只有一列 int 类型的全新表,添加一些数据,然后将其更改为 varint 类型,则会出现同样的问题。将列类型从 int 更改为 varint 是否存在某种错误?