本文介绍了在Cassandra CQL2中选择语句不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题 -
我可以在CQL2中不存在的列值上使用select语句检索结果(但是在CQL3中不会发生);有人可以解释这个给我吗?

Question - I am able to retrieve results with a select statement on a non-existent column value in CQL2 (this does not happen in CQL3 however); can someone explain this to me ?

你明白为什么我会在我的select查询中得到一个不存在的C0列值('test')的结果?
我没有得到它 - 见下面:
必须有一些配置错误,但是什么?

Do you understand why I would get a result on my select query with a non existent C0 column value ('test') ?I don’t get it – see below:There must be something misconfigured, but what ?

cqlsh> use Keyspace1;
cqlsh:Keyspace1> CREATE COLUMNFAMILY users (
             ... KEY varchar PRIMARY KEY,
             ... gender varchar,
         ... birth_year bigint);
cqlsh:Keyspace1> INSERT INTO users (KEY, gender, birth_year) VALUES ('TEST', 'm', 1968);
cqlsh:Keyspace1> select * from users;
 KEY  | birth_year | gender
------+------------+--------
 TEST |       1968 |      m

cqlsh:Keyspace1> select * from users where key = 'TEST';
 KEY  | birth_year | gender
------+------------+--------
 TEST |       1968 |      m

cqlsh:Keyspace1> CREATE INDEX birth_year_key ON users (birth_year);
cqlsh:Keyspace1> CREATE INDEX gender_key ON users (gender);
cqlsh:Keyspace1> select * from users where key = 'TEST' and birth_year = 1968;
 KEY  | birth_year | gender
------+------------+--------
 TEST |       1968 |      m

cqlsh:Keyspace1> select * from users where  birth_year = 1968;
 KEY  | birth_year | gender
------+------------+--------
 TEST |       1968 |      m

到目前为止,很好,但现在看:

so far, so good, but now watch:

cqlsh:Keyspace1> select * from users where key = 'TEST' and birth_year = 1962;
 KEY  | birth_year | gender
------+------------+--------
 TEST |       1968 |      m

这是怎么回事?
感谢,
马特

What is going on, here ? Thanks,Matt

推荐答案

听起来像是CQL2中的一个错误。

Sounds like a bug in CQL2 to me.

这里是事情:基本上CQL2仍然是唯一的原因是,使少数应用程序编写反对它继续工作。不会添加新功能,也不会修复任何错误(因为这可能会导致其他地方的回归)。

Here's the thing: basically the only reason CQL2 is still around is so that the few applications written against it continue to work. No new features will be added and no bugs will be fixed (because that might cause regressions elsewhere).

因此,如果你正在构建一个新的应用程序,你应该绝对使用CQL3。不要认为CQL2是任何有意义的意义上的替代。请参见,详细分析了CQL2的缺点,促使我们创建CQL3作为替代品。

So if you are building a new application you should absolutely use CQL3. Don't think of CQL2 as an alternative in any meaningful sense of the word. See http://www.datastax.com/dev/blog/cql3-for-cassandra-experts for a detailed breakdown of the shortcomings of CQL2 that drove us to create CQL3 as a replacement.

这篇关于在Cassandra CQL2中选择语句不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 18:18