example query on subselect in SPARQL/Query Section 3

Next thing, I don't get my head around is the subselect example:

PREFIX : <http://people.example/>
SELECT ?y ?name WHERE {
   :alice :knows ?y .
   {
     SELECT ?y ?name WHERE {
       ?y :name ?name
     }
     ORDER BY ?name
     LIMIT 1
   }
}

I believe that doesn't work with the current - compositional -  
semantics of subselect, as subselect uses normal Join.
I am afraid, we need something else to get the intended behavior.
That is, that the subselect is executed order-dependent LEFT- 
associative with the bindings coming from OUTSIDE,
being replaced. We have something similar OPTIONALs (and particularly   
FITLERs in OPTIONALs) in the language already,
it would though be another case where we'd give up compositionality.

I think usability-wise giving up compositionality might make sense  
here for certain cases. Although we discussed at
F2F that the above query could be done with aggregates alone, I assume  
if you want to do a modified query such as
you want to have *at most two* names per :alice's friend, that  
couldn't be done with aggregates alone easily, i.e.,

PREFIX : <http://people.example/>
SELECT ?y ?name WHERE {
   :alice :knows ?y .
   {
     SELECT ?y ?name WHERE {
       ?y :name ?name
     }
     ORDER BY ?name
     LIMIT *2*
   }
}

Opinions?

best,
Axel

Received on Thursday, 5 November 2009 18:47:41 UTC