【问题标题】:where condition for date & time is not working日期和时间条件不起作用的地方
【发布时间】:2014-09-27 20:07:30
【问题描述】:

我想执行这个查询,

从标准事件0805 中选择 uuid、数据、名称、时间、跟踪器、类型、用户 ID 其中时间 > '2014/08/04 00:00:00'; (我也尝试在双引号中加上“2014/08/04 00:00:00”)

但它不能正常工作。

下面是我的列族的描述,

CREATE TABLE standardevents0805 (
  uuid timeuuid PRIMARY KEY,
  data text,
  name text,
  time timestamp,
  tracker text,
  type text,
  userid text
) WITH
  bloom_filter_fp_chance=0.010000 AND
  caching='KEYS_ONLY' AND
  comment='' AND
  dclocal_read_repair_chance=0.000000 AND
  gc_grace_seconds=864000 AND
  read_repair_chance=0.100000 AND
  replicate_on_write='true' AND
  populate_io_cache_on_flush='false' AND
  compaction={'class': 'SizeTieredCompactionStrategy'} AND
  compression={'sstable_compression': 'SnappyCompressor'};

CREATE INDEX time_in ON standardevents0805 (time);

CREATE INDEX userid_in ON standardevents0805 (userid);

【问题讨论】:

  • 您想使用 timeuuid 而不是时间戳,these slides 给出了如何构建时间线的可靠概述。
  • 在我以前的表数据类型中,时间是 varchar,所以在新表中,我将表创建为 timeuuid,并尝试复制它不允许的数据,但它不会允许,这是显而易见的。那么除了timeuuid我们不能及时执行条件吗?

标签: cassandra cqlsh


【解决方案1】:

您已按时放置了查找索引,但此类索引(在撰写本文时)仅允许等于操作。范围查询只能在聚类键上执行。

【讨论】:

  • 同样的方式,即使我从 standardevents0805 中查询 select count(*) where time='2014/08/04 00:00:00' limit 100;('2014/08/04 ')它给了我错误,例如无法将'2014/08/04 00:00:00'强制转换为格式化日期(长)。我肯定会使用集群键执行..
  • 如果我通过 select * from tablename 看到正常输出,那么它只给我上述格式的时间字段。
猜你喜欢
  • 2017-08-06
  • 1970-01-01
  • 2016-06-02
  • 2017-03-28
  • 1970-01-01
  • 2017-09-22
  • 2018-09-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多