namhnguyen / asterixdb

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

order-by doesnt work when the primary-key of the table contains the field you ordered-by #759

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If you order by a field and you primary-key by that field (or a composite key 
with it), then the order by doesn't work.
To get the right order, you would remove the field you order-by from the 
primary key.

Reproduction:
=============
drop dataverse kereno if exists;
create dataverse kereno;
use dataverse kereno;

create type page_info_type as open {}

create type page_views_type as closed {
        id: int32, 
        user: string,
        action: int32,
        timespent: int32,
        query_term: string?,
        ip_addr: int32,
        timestamp: int32,
        estimated_revenue: double?,
        page_info: page_info_type,
        page_links: {{ page_info_type}}?
}

create dataset page_views(page_views_type)
//primary key id, action, ip_addr, timestamp; //more tests
primary key id, user;

load dataset page_views using localfs
(("path"="127.0.0.1:///home/kereno/benchmarking/asterix/ADM-format/page_views/pa
rt-m-00000"),("format"="adm"));

for $i in dataset page_views
order by $i.user
return {"user":$i.user};

Results of the query returns: 
=============================
{ "user": "\\kHtbWKUnW]qxVJMp`" }
{ "user": "p_GsuyPAmXXoTU]dWAOGiN" }
{ "user": "Bk`lbryiG_^L]pwauZnY_`ni" }
{ "user": "Y^DTPaI\\dluolr^D" }
{ "user": "USmJryrLmVKqej\\DKbRWVb" }
{ "user": "Bk`lbryiG_^L]pwauZnY_`ni" }
{ "user": "hwwLnfvO[hI`xh[PG_" }
{ "user": "FJs[DWxaZrUjRmBBNq" }
{ "user": "tb\\o_eWlShGfUNlSy" }
{ "user": "GgXLlD_DywTuUgo]X]" }

Whereas it should be:
=======================
To get these results, just remove the user field from the primary key.
{ "user": "Bk`lbryiG_^L]pwauZnY_`ni" }
{ "user": "Bk`lbryiG_^L]pwauZnY_`ni" }
{ "user": "FJs[DWxaZrUjRmBBNq" }
{ "user": "GgXLlD_DywTuUgo]X]" }
{ "user": "USmJryrLmVKqej\\DKbRWVb" }
{ "user": "Y^DTPaI\\dluolr^D" }
{ "user": "\\kHtbWKUnW]qxVJMp`" }
{ "user": "hwwLnfvO[hI`xh[PG_" }
{ "user": "p_GsuyPAmXXoTU]dWAOGiN" }
{ "user": "tb\\o_eWlShGfUNlSy" }

Original issue reported on code.google.com by ker...@gmail.com on 22 Apr 2014 at 11:06

Attachments:

GoogleCodeExporter commented 9 years ago
Verified by Abdullah.

Original comment by buyingyi@gmail.com on 25 Oct 2014 at 7:50