The following query fails for an IndexOutOfBound exception when it checks the
type in DataScan:
drop dataverse test if exists;
create dataverse test;
use dataverse test;
create type Type1 as closed {
id: int32,
items: [{
subid: string,
value: int32
}]
}
create type Type2 as closed {
id: string,
val: int32
}
create dataset Dataset1(Type1) primary key id;
create dataset Dataset2(Type2) primary key id;
insert into dataset Dataset1 (
{ "id": 1, "items": [ { "subid": "2", "value": 1 }, { "subid": "4", "value": 1111 } ] }
)
insert into dataset Dataset1 (
{ "id": 2, "items": [ { "subid": "0", "value": 1 }, { "subid": "1", "value": 2222 } ] }
)
insert into dataset Dataset2 (
{ "id": "0", "val": 0 }
)
insert into dataset Dataset2 (
{ "id": "1", "val": 1 }
)
insert into dataset Dataset2 (
{ "id": "2", "val": 2 }
)
insert into dataset Dataset2 (
{ "id": "3", "val": 3 }
)
insert into dataset Dataset2 (
{ "id": "4", "val": 4 }
)
for $i in dataset Dataset1
for $j in $i.items
return {
"id": $i.id,
"items":
for $k in dataset Dataset2
return {
"subid": $k.id,
"value": switch-case($k.id = $j.subid, true, $j.value, false, $k.val)
}
}
However if the dataset2 is assigned using LET, the following query works:
let $cs := for $k in dataset Dataset2 return $k
for $i in dataset Dataset1
for $j in $i.items
return {
"id": $i.id,
"items":
for $k in $cs
return {
"subid": $k.id,
"value": switch-case($k.id = $j.subid, true, $j.value, false, $k.val)
}
}
Initially assigned to Yingyi as it involves the type promotion issue. Also cc
to Sattam since the exception happens when the type check is processed on index
accessing.
Original issue reported on code.google.com by jarod...@gmail.com on 4 Sep 2013 at 5:15
Original issue reported on code.google.com by
jarod...@gmail.com
on 4 Sep 2013 at 5:15