gpt4 book ai didi

Cassandra : Select records based on "timeuuid where conditions"

转载 作者:行者123 更新时间:2023-12-01 09:52:30 27 4
gpt4 key购买 nike

我在 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: Invalid STRING constant (2045d660-9415-11e5-9742-c53da2f1a8ec) for "trade" of type timeuuid
我尝试了以下查询也没有运气
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');

最佳答案

删除 UUID 周围的引号。 Cassandra 对它们有本地支持,而不是通过字符串。

select * from shahid.stock_ticks  where symbol = 'NFLX' and date = 1 and trade < 2045d660-9415-11e5-9742-c53da2f1a8ec;

关于 Cassandra : Select records based on "timeuuid where conditions",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34993031/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com