What steps will reproduce the problem?
let $sample :=
{{
{"r": 1, "uid": "1a2b", "t": datetime("2000-01-01T01:00:00"), "event": "e1"},
{"r": 2, "uid": "1a2b", "t": datetime("2000-01-01T01:01:00"), "event": "e2"},
{"r": 3, "uid": "3c4d", "t": datetime("2000-01-01T01:02:00"), "event": "e1"},
{"r": 4, "uid": "3c4d", "t": datetime("2000-01-01T01:03:00"), "event": "e3"},
{"r": 5, "uid": "1a2b", "t": datetime("2000-01-01T01:04:00"), "event": "e1"},
{"r": 6, "uid": "1a2b", "t": datetime("2000-01-01T01:05:00"), "event": "e4"}
}}
for $s1 in $sample
for $s2 in $sample
where $s1.uid = $s2.uid
and $s1.t < $s2.t
let $pair := { "s1": $s1, "s2": $s2 }
group by $s1.uid, $s1.t with $pair
let $next :=
for $p in $pair
order by $p.s2.t
limit 1
return $p
return $next
This should return all adjacent pairs of events for each uid; it returns the
right number of results but the last three are empty for some reason:
[ { "s1": { "r": 1, "uid": "1a2b", "t": datetime("2000-01-01T01:00:00.000Z"),
"event": "e1" }, "s2": { "r": 2, "uid": "1a2b", "t":
datetime("2000-01-01T01:01:00.000Z"), "event": "e2" } } ]
[ ]
[ ]
[ ]
Original issue reported on code.google.com by dtab...@gmail.com on 12 Jul 2013 at 9:28
Original issue reported on code.google.com by
dtab...@gmail.com
on 12 Jul 2013 at 9:28