我在Cassandra中创建了一张表,并想根据列的timeuuid类型的where条件选择数据。
CREATE TABLE shahid.stock_ticks(
symbol varchar,
date int,
trade timeuuid,
trade_details text,
PRIMARY KEY ( (symbol, date), trade )
) WITH CLUSTERING ORDER BY (trade DESC) ;
INSERT INTO shahid.stock_ticks (symbol, date, trade, trade_details) VALUES ('NFLX', 1, now(), 'this is 10' );
INSERT INTO shahid.stock_ticks (symbol, date, trade, trade_details) VALUES ('NFLX', 1, now(), 'this is 2' );
INSERT INTO shahid.stock_ticks (symbol, date, trade, trade_details) VALUES ('NFLX', 1, now(), 'this is 3' );
上面的查询已经插入了记录,其中一个记录在交易列中有值'2045d660-9415-11e5-9742-c53da2f1a8ec'。
我想这样选择,但是它报错了。
select * from shahid.stock_ticks where symbol = 'NFLX' and date = 1 and trade < '2045d660-9415-11e5-9742-c53da2f1a8ec';
下面显示了错误信息:
InvalidQueryException: 对于类型为timeuuid的“trade”,字符串常量无效(2045d660-9415-11e5-9742-c53da2f1a8ec )
我尝试了以下查询,但没有成功。
select * from shahid.stock_ticks where symbol = 'NFLX' and date = 1 and trade < maxTimeuuid('2045d660-9415-11e5-9742-c53da2f1a8ec');
select * from shahid.stock_ticks where symbol = 'NFLX' and date = 1 and trade < dateOf('2045d660-9415-11e5-9742-c53da2f1a8ec');
select * from shahid.stock_ticks where symbol = 'NFLX' and date = 1 and trade < unixTimestampOf('2045d660-9415-11e5-9742-c53da2f1a8ec');