br1ghtyang / asterixdb

Automatically exported from code.google.com/p/asterixdb
0 stars 0 forks source link

Bug in a query involving a group-by and a nested query with a limit clause in it #551

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Run the following query:

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 $s in $sample
group by $u := $s.uid with $s 
return {
   "u": $u,
   "recs": ( for $srec in $s
                    order by $srec.t
                    limit 2
                    return $srec )
 };

What is the expected output?

{ "u": "1a2b", "recs": [ { "r": 1, "uid": "1a2b", "t": 
datetime("2000-01-01T01:00:00.000Z"), "event": "e1" }, { "r": 2, "uid": "1a2b", 
"t": datetime("2000-01-01T01:01:00.000Z"), "event": "e2" } ] }
{ "u": "3c4d", "recs": [ { "r": 3, "uid": "3c4d", "t": 
datetime("2000-01-01T01:02:00.000Z"), "event": "e1" }, { "r": 4, "uid": "3c4d", 
"t": datetime("2000-01-01T01:03:00.000Z"), "event": "e3" } ] }

What do you see instead?

{ "u": "1a2b", "recs": [ { "r": 1, "uid": "1a2b", "t": 
datetime("2000-01-01T01:00:00.000Z"), "event": "e1" }, { "r": 2, "uid": "1a2b", 
"t": datetime("2000-01-01T01:01:00.000Z"), "event": "e2" } ] }
{ "u": "3c4d", "recs": [  ] }

Original issue reported on code.google.com by dtab...@gmail.com on 4 Jul 2013 at 6:02

GoogleCodeExporter commented 8 years ago
(The limit should be per-group but seems to be global - looks like a rewrite 
rule bug related to limit handling?)

Original comment by dtab...@gmail.com on 4 Jul 2013 at 6:03

GoogleCodeExporter commented 8 years ago

Original comment by buyingyi@gmail.com on 9 Oct 2014 at 6:38