br1ghtyang / asterixdb

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

Error in grouping query if a "group by" and a "with" variable are returned. #456

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Assuming a dataverse setup like this:

    drop dataverse test if exists;

    create dataverse test;

    use dataverse test;

    create type TypeOpen as open {
      id : int32,
      int_m : int32,
      int_o : int32?,
      string_m : string,
      string_o : string?
    };

    create dataset DataOpen(TypeOpen) primary key id;

    insert into dataset DataOpen({ "id": 0, "int_m": 1, "int_o": 1, "string_m": "a", "string_o": "a" });
    insert into dataset DataOpen({ "id": 1, "int_m": 1, "int_o": 1, "string_m": "a", "string_o": null });
    insert into dataset DataOpen({ "id": 2, "int_m": 1, "int_o": 1, "string_m": "b", "string_o": "a" });
    insert into dataset DataOpen({ "id": 3, "int_m": 1, "int_o": 1, "string_m": "b", "string_o": null });
    insert into dataset DataOpen({ "id": 4, "int_m": 1, "int_o": null, "string_m": "a", "string_o": "a" });
    insert into dataset DataOpen({ "id": 5, "int_m": 1, "int_o": null, "string_m": "a", "string_o": null });
    insert into dataset DataOpen({ "id": 6, "int_m": 1, "int_o": null, "string_m": "b", "string_o": "a" });
    insert into dataset DataOpen({ "id": 7, "int_m": 1, "int_o": null, "string_m": "b", "string_o": null });
    insert into dataset DataOpen({ "id": 8, "int_m": 2, "int_o": 1, "string_m": "a", "string_o": "a" });
    insert into dataset DataOpen({ "id": 9, "int_m": 2, "int_o": 1, "string_m": "a", "string_o": null });
    insert into dataset DataOpen({ "id": 10, "int_m": 2, "int_o": 1, "string_m": "b", "string_o": "a" });
    insert into dataset DataOpen({ "id": 11, "int_m": 2, "int_o": 1, "string_m": "b", "string_o": null });
    insert into dataset DataOpen({ "id": 12, "int_m": 2, "int_o": null, "string_m": "a", "string_o": "a" });
    insert into dataset DataOpen({ "id": 13, "int_m": 2, "int_o": null, "string_m": "a", "string_o": null });
    insert into dataset DataOpen({ "id": 14, "int_m": 2, "int_o": null, "string_m": "b", "string_o": "a" });
    insert into dataset DataOpen({ "id": 15, "int_m": 2, "int_o": null, "string_m": "b", "string_o": null });

this query works

    for $x in dataset DataOpen
    let $id := $x.id
    group by $m := $x.int_m with $id
    return $id

    [ 0, 1, 2, 3, 4, 5, 6, 7 ]
    [ 8, 9, 10, 11, 12, 13, 14, 15 ]

and this query works

    for $x in dataset DataOpen
    let $id := $x.id
    group by $m := $x.int_m with $id
    return $m

    1
    2

but this one crashes:

    for $x in dataset DataOpen
    let $id := $x.id
    group by $m := $x.int_m with $id
    return [ $m, $id ]

with

    edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException:
    edu.uci.ics.hyracks.api.exceptions.HyracksException: Job Failed

(Ok, the message is not very helpful right now.)

Original issue reported on code.google.com by westm...@gmail.com on 17 May 2013 at 12:48

GoogleCodeExporter commented 8 years ago
Adding some more information, 

let $a := {"r1":1234}
let $b := {"r2":456}
return [ $a,$b ]

results :

[ {  }, {  } ]

Original comment by khfaraaz82 on 17 May 2013 at 1:01

GoogleCodeExporter commented 8 years ago
Khurram, I think that it's not clear that this is the same problem, so I've 
file issue 465 for this.

Original comment by westm...@gmail.com on 21 May 2013 at 6:48

GoogleCodeExporter commented 8 years ago
Yingyi, could you take a look at this one?
Please send it back, if you are too busy.

Original comment by westm...@gmail.com on 24 May 2013 at 12:33

GoogleCodeExporter commented 8 years ago

Original comment by westm...@gmail.com on 24 May 2013 at 12:35

GoogleCodeExporter commented 8 years ago

Original comment by westm...@gmail.com on 28 May 2013 at 5:52

GoogleCodeExporter commented 8 years ago
INFO: Optimized Plan:
distribute result [%0->$$8]
-- DISTRIBUTE_RESULT  |PARTITIONED|
  exchange 
  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
    project ([$$8])
    -- STREAM_PROJECT  |PARTITIONED|
      assign [$$8] <- [function-call: ASTERIX_PRIVATE:ordered-list-constructor, Args:[%0->$$2, %0->$$7]]
      -- ASSIGN  |PARTITIONED|
        exchange 
        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
          group by ([$$2 := %0->$$9]) decor ([]) {
                    aggregate [$$7] <- [function-call: ASTERIX_PRIVATE:listify, Args:[%0->$$10]]
                    -- AGGREGATE  |LOCAL|
                      nested tuple source
                      -- NESTED_TUPLE_SOURCE  |LOCAL|
                 }
          -- PRE_CLUSTERED_GROUP_BY[$$9]  |PARTITIONED|
            exchange 
            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
              order (ASC, %0->$$9) 
              -- STABLE_SORT [$$9(ASC)]  |PARTITIONED|
                exchange 
                -- HASH_PARTITION_EXCHANGE [$$9]  |PARTITIONED|
                  project ([$$9, $$10])
                  -- STREAM_PROJECT  |PARTITIONED|
                    assign [$$9] <- [function-call: ASTERIX_PRIVATE:field-access-by-index, Args:[%0->$$0, AInt32: {1}]]
                    -- ASSIGN  |PARTITIONED|
                      exchange 
                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                        data-scan []<-[$$10, $$0] <- test:DataOpen
                        -- DATASOURCE_SCAN  |PARTITIONED|
                          exchange 
                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                            empty-tuple-source
                            -- EMPTY_TUPLE_SOURCE  |PARTITIONED|

Original comment by westm...@gmail.com on 30 May 2013 at 6:51

GoogleCodeExporter commented 8 years ago

Original comment by westm...@gmail.com on 4 Jun 2013 at 12:34

GoogleCodeExporter commented 8 years ago

Original comment by westm...@gmail.com on 4 Jun 2013 at 5:28

GoogleCodeExporter commented 8 years ago
drop dataverse test if exists;

    create dataverse test;

    use dataverse test;

    create type TypeOpen as open {
      id : int32,
      int_m : int32,
      int_o : int32?,
      string_m : string,
      string_o : string?
    };

    create dataset DataOpen(TypeOpen) primary key id;

    insert into dataset DataOpen({ "id": 0, "int_m": 1, "int_o": 1, "string_m": "a", "string_o": "a" });
    insert into dataset DataOpen({ "id": 1, "int_m": 1, "int_o": 1, "string_m": "a", "string_o": null });
    insert into dataset DataOpen({ "id": 2, "int_m": 1, "int_o": 1, "string_m": "b", "string_o": "a" });
    insert into dataset DataOpen({ "id": 3, "int_m": 1, "int_o": 1, "string_m": "b", "string_o": null });
    insert into dataset DataOpen({ "id": 4, "int_m": 1, "int_o": null, "string_m": "a", "string_o": "a" });
    insert into dataset DataOpen({ "id": 5, "int_m": 1, "int_o": null, "string_m": "a", "string_o": null });
    insert into dataset DataOpen({ "id": 6, "int_m": 1, "int_o": null, "string_m": "b", "string_o": "a" });
    insert into dataset DataOpen({ "id": 7, "int_m": 1, "int_o": null, "string_m": "b", "string_o": null });
    insert into dataset DataOpen({ "id": 8, "int_m": 2, "int_o": 1, "string_m": "a", "string_o": "a" });
    insert into dataset DataOpen({ "id": 9, "int_m": 2, "int_o": 1, "string_m": "a", "string_o": null });
    insert into dataset DataOpen({ "id": 10, "int_m": 2, "int_o": 1, "string_m": "b", "string_o": "a" });
    insert into dataset DataOpen({ "id": 11, "int_m": 2, "int_o": 1, "string_m": "b", "string_o": null });
    insert into dataset DataOpen({ "id": 12, "int_m": 2, "int_o": null, "string_m": "a", "string_o": "a" });
    insert into dataset DataOpen({ "id": 13, "int_m": 2, "int_o": null, "string_m": "a", "string_o": null });
    insert into dataset DataOpen({ "id": 14, "int_m": 2, "int_o": null, "string_m": "b", "string_o": "a" });
    insert into dataset DataOpen({ "id": 15, "int_m": 2, "int_o": null, "string_m": "b", "string_o": null });

for $x in dataset DataOpen
    let $id := $x.id
    group by $m := $x.int_m with $id
    return [ $m, $id ]

Results:

[ 1, [ 0, 1, 2, 3, 4, 5, 6, 7 ] ]
[ 2, [ 8, 9, 10, 11, 12, 13, 14, 15 ] ]

Original comment by khfaraaz82 on 4 Jun 2013 at 8:07