短いバージョン: 特定の日付に対応するすべての timeuuid 列を照会することは可能ですか?
詳細:
次のように定義されたテーブルがあります。
CREATE TABLE timetest(
key uuid,
activation_time timeuuid,
value text,
PRIMARY KEY(key,activation_time)
);
次のように、これに単一の行を入力しました (f0532ef0-2a15-11e3-b292-51843b245f21
は日付に対応する timeuuid です2013-09-30 22:19:06+0100
)。
insert into timetest (key, activation_time, value) VALUES (7daecb80-29b0-11e3-92ec-e291eb9d325e, f0532ef0-2a15-11e3-b292-51843b245f21, 'some value');
そして、次のようにその行を照会できます。
select activation_time,dateof(activation_time) from timetest where key=7daecb80-29b0-11e3-92ec-e291eb9d325e
結果は次のようになります(cqlshを使用)
activation_time | dateof(activation_time)
--------------------------------------+--------------------------
f0532ef0-2a15-11e3-b292-51843b245f21 | 2013-09-30 22:19:06+0100
ここで、テーブルに大量のデータがありactivation_time
、特定の日付に対応するすべての行を取得したいとします2013-09-30 22:19:06+0100
。
minTimeuuid('2013-09-30 22:19:06+0100')
との間のすべての timeuuid の範囲をクエリできると期待していましたmaxTimeuuid('2013-09-30 22:19:06+0100')
が、これは不可能のようです (次のクエリはゼロ行を返します)。
select * from timetest where key=7daecb80-29b0-11e3-92ec-e291eb9d325e and activation_time>minTimeuuid('2013-09-30 22:19:06+0100') and activation_time<=maxTimeuuid('2013-09-30 22:19:06+0100');
行をキャッチするために、クエリの2番目の日付を(1秒ずつ)インクリメントするハックを使用する必要があるようです。つまり、
select * from timetest where key=7daecb80-29b0-11e3-92ec-e291eb9d325e and activation_time>minTimeuuid('2013-09-30 22:19:06+0100') and activation_time<=maxTimeuuid('2013-09-30 22:19:07+0100');
これは間違っていると感じます。何か不足していますか?これを行うためのよりクリーンな方法はありますか?
CQL ドキュメントではtimeuuid 関数について説明していますが、timeuuid を使用した gte/lte 式についてはかなり短いです。
min/maxTimeuuid の例では、timeuuid 列 t が厳密に 2013-01-01 00:05+0000 より遅く、2013-02-02 10:00+0000 より厳密に早いすべての行を選択します。t >= maxTimeuuid('2013-01-01 00:05+0000') は、正確に 2013-01-01 00:05+0000 で生成された timeuuid を選択せず、本質的に t > maxTimeuuid('2013-01 -01 00:05+0000')。
ps 次のクエリもゼロ行を返します。
select * from timetest where key=7daecb80-29b0-11e3-92ec-e291eb9d325e and activation_time<=maxTimeuuid('2013-09-30 22:19:06+0100');
次のクエリは行を返します。
select * from timetest where key=7daecb80-29b0-11e3-92ec-e291eb9d325e and activation_time>minTimeuuid('2013-09-30 22:19:06+0100');