Cassandra-根据WHERE子句选择返回空值

时间:2018-08-31 05:15:06

标签: cassandra datastax cql

我们有以下声明:

SELECT id, creationuser, lastversion FROM fenix
WHERE id = 96809ff7-313d-4c02-b9af-6ac38ae3df58 and lastversion = true LIMIT 1;

以及以下结果:

------------------------------------------------------------------+
id                                   | creationuser | lastversion |
------------------------------------------------------------------+
96809ff7-313d-4c02-b9af-6ac38ae3df58 | <<null>>     | true        |
------------------------------------------------------------------+

请注意,尚未填充creationuser列。

但是,当我们执行以下语句时(修改了where clausure):

SELECT id, creationuser, lastversion FROM fenix
WHERE Id = 96809ff7-313d-4c02-b9af-6ac38ae3df58 limit 1;

我们得到了不同的结果:

------------------------------------------------------------------+
id                                   | creationuser | lastversion |
------------------------------------------------------------------+
96809ff7-313d-4c02-b9af-6ac38ae3df58 | user_fenix1  | true        |
------------------------------------------------------------------+

为什么更改WHERE子句会得到不同的结果?为什么将<<null>>值返回到现有值?

[编辑]

表结构:

CREATE TABLE fenix (
      id                uuid,
      creationuser      text,
      lastversion       bool,
      creationdate      timestamp,
      editiondate       timestamp,
      PRIMARY KEY (id, creationdate, editiondate)
)WITH CLUSTERING ORDER BY(creationdate DESC, editiondate DESC);

表中的完整数据:

--------------------------------------------------------------------------------------------------------------------------+
id                                   | creationuser | lastversion | creationdate               | editiondate              |
--------------------------------------------------------------------------------------------------------------------------+
96809ff7-313d-4c02-b9af-6ac38ae3df58 | user_fenix1  | true        | 2018-08-31 04:50:13+0000   | 2018-08-31 04:50:13+0000 |
--------------------------------------------------------------------------------------------------------------------------+
96809ff7-313d-4c02-b9af-6ac38ae3df58 | user_fenix1  | false       | 2018-08-31 04:50:13+0000   | 2018-08-31 04:50:13+0000 |
--------------------------------------------------------------------------------------------------------------------------+

CREATE SEARCH INDEX ON fenix WITH lastversion;

0 个答案:

没有答案