选择Cassandra中列为空的行

编程入门 行业动态 更新时间:2024-10-23 22:23:37
本文介绍了选择Cassandra中列为空的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在Cassandra中有下表(CQL规范3.3.0):-

I have following table in Cassandra (CQL spec 3.3.0 ):-

Users: <a,b,c,d>, Primary key a Int, B: Map<Int,Date>

用户表的列名称为 a,b,c,d 。现在,我想为b列为 null 的行选择所有列。我做了以下查询:-

Where Users table has column names as a,b,c,d. Now I want to select all the columns for the rows where column b is null. I did following query:-

select from Users where b = null;

但这会失败,并显示错误= message =

but this fails with error = "message="Invalid null value in condition"

  • 答案在这里:-空值不存在的记录阐明了语义为null,但仍然不清楚我如何选择不连续显示的列?
  • 此处卡桑德拉(Cassandra)中为空答案声称最新的卡桑德拉(cassandra)支持null,但似乎不适用于地图。
  • The answer here:- null doesn't exists clarifies the semantics of null but still its not clear how do I select the columns which are not present in a row?
  • Here Nulls in Cassandra an answer claims null to be supported by latest cassandra, but looks like it doesn't work for maps.
  • 有什么方法可以解决?还是应该从所有行中选择所有列,然后以编程方式手动检查null,当然,对于大型数据库而言,效率非常低。

    Is there any way to solve it? Or should I select all the columns from all the rows and manually check null programmatically, which of course would be very inefficient for a large database.

    推荐答案

    Cassandra不支持基于null的查询,甚至f或二级索引。

    Cassandra doesn't support querying based on null, even for secondary indexes.

    您可以在表中添加另一个字段,例如 uninitialized,作为布尔值,当您首次插入该行时将其设置为true,然后将在未初始化字段上创建二级索引。

    You could add another field to your table called something like "uninitialized" as a boolean that you set to true when you first insert the row, and you'd create a secondary index on the "uninitialized" field.

    将地图设置为某些内容时,会将未初始化设置为false。然后要查找地图为空的行,请查询未初始化为true的行。

    When you set the map to something, you would set "uninitialized" to false. Then to find the rows where the map is null, you'd query for rows where "uninitialized" is true.

    更多推荐

    选择Cassandra中列为空的行

    本文发布于:2023-10-24 13:47:02,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1524102.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:为空   Cassandra

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!