- From: Steve Harris <steve.harris@garlik.com>
- Date: Fri, 6 Nov 2009 12:25:35 +0000
- To: Axel Polleres <axel.polleres@deri.org>
- Cc: SPARQL Working Group <public-rdf-dawg@w3.org>
On 5 Nov 2009, at 18:46, Axel Polleres wrote: > 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. Indeed. That's my fault, I still find it difficult to mentally process bottom-up semantics in SPARQL for some reason. > 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? SQL has bottom up join semantics in this case, so doing something else with the algebra here may cause too much surprise. If is an interesting usecase though. It could be addressed with a GROUP_CONCAT and REGEX modification (if we include those), but that might not be a very satisfactory solution :) - Steve -- Steve Harris, CTO, Garlik Limited 2 Sheen Road, Richmond, TW9 1AE, UK +44(0)20 8973 2465 http://www.garlik.com/ Registered in England and Wales 535 7233 VAT # 849 0517 11 Registered office: Thames House, Portsmouth Road, Esher, Surrey, KT10 9AD
Received on Friday, 6 November 2009 12:26:05 UTC