Hi Riyafa,

I agree with your expected results and at first glance it looks like an
implementation issue to me.
It seems that the direct application of the object key listing on an object
results in a different plan than doing the same operation through a
let-variable.
To find the issue I would try to look at the different optimized plans for
both queries and see what the difference between the plans is. It almost
looks like the object key listing is not executed and so it might be that it
is not part of the plan (even though that seems highly unlikely).
If it is part of the plan, it would be interesting to find out what exactly the data model instance looks like that is passed from the key access to the object key listing. Using fn:trace to do that might be a good first step.

Does this help?

Cheers,
Till

On 5 Aug 2016, at 7:42, Riyafa Abdul Hameed wrote:

Hi,

When looking for a good example for the documentation, I came across the
following issue in Object key listing and Array unboxing:

The code

let $x := {
“name” : {“id” : 123, “first” : “Riyafa”, “Last” : “Abdul
Hameed”}}return $x(“name”)()

returns

{“id” : 123, “first” : “Riyafa”, “Last” : “Abdul Hameed”}

but the code,

let $x := {
“name” : {“id” : 123, “first” : “Riyafa”, “Last” : “Abdul Hameed”}}
let $y := $x(“name”)return $y()

returns

id
first
Last

But, as I understand both code should return:

id
first
Last

The same issue is present in Array unboxing:
For example the code

let $x := [[ “mercury”, “venus”, “earth”, “mars” ],[ “monday”,
“tuesday”, “wednesday”, “thursday” ]]return $x(1)()

returns

[ “mercury”, “venus”, “earth”, “mars” ]


while the code

let $x := [[ “mercury”, “venus”, “earth”, “mars” ],[ “monday”,
“tuesday”, “wednesday”, “thursday” ]]
let $y := $x(1)return $y()

returns

mercury
venus
earth
mars

Here also I think both should return:

mercury
venus
earth
mars

I would like to know whether this is a language feature or if its an
implementation issue. If it’s an implementation issue I am not sure I understand where the issue is. Any suggestions would be highly appreciated.
​
--
Riyafa Abdul Hameed
Undergraduate, University of Moratuwa

Email: [email protected]
Website: https://riyafa.wordpress.com/ <http://riyafa.wordpress.com/>
<http://facebook.com/riyafa.ahf>  <http://lk.linkedin.com/in/riyafa>
<http://twitter.com/Riyafa1>

Reply via email to