Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
First, I observed the out of range access for the closed-type list and open-type list are quite different:
// closed type: let $all := [ { "ka":"a1", "kb":"b1"}, { "ka":"a2", "kb":"b2"}] return $all[3].ka
It returns a "", I think it should be null.
If I change the type to a hytogenous type like below
// open type: let $all := [ { "ka":"a1", "kb":"b1"}, { "ka":2, "kb":"b2"}] return $all[3].ka
It returns a null as expected.
Furthermore, the closed-type will return the wrong result by just access field by index other than by name. Here is example
let $all := [ { "ka":"a1", "kb":"b1"}, { "ka":"a2", "kb":"b2"}] for $x in $all group by $k := $x.kb with $x return { "g": $k, "s1": $x[1].ka}
It returns
{ "g": "b1", "s1": "b1" } { "g": "b2", "s1": "b2" }
It seems it skipped some offset directly without verify if the record is null or not.
The open type doesn't have this problem. The following code
let $all := [ { "ka":"a1", "kb":"b1"}, { "ka":2, "kb":"b2"}] // change ka to 2 to make a heterogenous type list for $x in $all group by $k := $x.kb with $x return { "g": $k, "s1": $x[1].ka}
will always return
{ "g": "b1", "s1": null } { "g": "b2", "s1": null }
Attachments
Issue Links
- is duplicated by
-
ASTERIXDB-905 Wrong results are returned upon asking for an item which doesn't exist
- Resolved