W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > October to December 2009

example query on subselect in SPARQL/Query Section 3

From: Axel Polleres <axel.polleres@deri.org>
Date: Thu, 5 Nov 2009 10:46:52 -0800
Message-Id: <0D38721A-B2C1-4380-AD25-DC4D15314A45@deri.org>
To: SPARQL Working Group <public-rdf-dawg@w3.org>
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:40 GMT