W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > July to September 2010

Re: limit per resource rethought...

From: Axel Polleres <axel.polleres@deri.org>
Date: Fri, 13 Aug 2010 13:16:55 +0100
Cc: Andy Seaborne <andy.seaborne@epimorphics.com>, Paul Gearon <gearon@ieee.org>
Message-Id: <23150111-168A-44D4-9A85-40A3AEEB8E63@deri.org>
To: Steve Harris <steve.harris@garlik.com>, SPARQL Working Group <public-rdf-dawg@w3.org>

On 13 Aug 2010, at 12:03, Steve Harris wrote:

> On 2010-08-13, at 11:53, Axel Polleres wrote:
> >
> > On 13 Aug 2010, at 11:29, Steve Harris wrote:
> >
> >> On 2010-08-13, at 10:21, Axel Polleres wrote:
> >>
> >>>
> >>> Just adding a few notes here:
> >>> 1)  LIMIT is actually not standard in SQL
> >>
> >> That's true, but it's rather widely implemented. I think MS SQL was the last to hold out, and they added it recently.
> >>
> >>> http://en.wikipedia.org/wiki/Select_%28SQL%29#Limiting_result_rows
> >>> in ISO SQL:2008 FETCH FIRST should work...
> >>
> >> That's just a standard way to write LIMIT, it doesn't alter the execution model.
> >>
> >>> 2) this SQL version using IN here, actually rather amounts to allowing IN along with unary SELECTs in FILTERs for us...
> >>>  which would reopen ISSUE-6 in which case the query would probably look be something like:
> >>>
> >>>  SELECT ?A ?B WHERE { ?A :knows ?B FILTER ( ?B IN ( SELECT ?B1 WHERE {?A :knows ?B1} LIMIT n ) ) }
> >>>
> >>> BTW, I acknowledge of course that this whole use case is kind of complementary to the original LIMIT per resource [1] use case
> >>
> >> And you still won't get the behaviour you'd like, it's evaluated bottom-up. See my other mail.
> >
> > Hmmm, I understood that FILTER's are always evaluated "per binding", i.e. the FILTER expression
> > is evaluated after the existing bindings have been replaced...
> We don't have any semantics for that kind of subquery in SPARQL, but in SQL that's not what happens. The subquery is executed first, so the FILTER/WHERE would always see the same table against the IN.
> > in that ontext, as for your other mail...
> >
> >> Your query - though not really equivalent to a SPARQL-style subquery,
> >
> > True, indeed, it would need subqueries allowed in IN in FILTERS with the mentioned behavior, i.e.
> > that existing bindings are "injected" in the FILTER before the subquery is evaluated.
> Right, which would mean that part of our algebra as top-down, and part bottom-up.

Hmmm, which is something we partially have already with FILTERs in OPTIONALs...?

> I suspect it would be very hard to specify that without introducing non-deterministic results.

As long as this only affected subqueries in FILTER evaluation (which though - admittedly - would imply reopening ISSUE-6), 
I can't see a big problem. As I said, aren't FILTERs already supposed to be evaluated only after replacement of the variables?

I am trying to sum up:

On the one hand, the specific use case might be viewed as new information, so it might be 
ok to reopen issues, such as ISSUE-6.

On the other hand, it all depends, I don't really know whether others also consider this use case as such valid for 
this round of SPARQL or exotic... Personally, I somehow had the (wrong) understanding that "LIMIT per resource" 
would also allow me to do this kind of queries, only now realising that it is orthogonal to the original "LIMIT 
per resource" use case.

 1) Do we consider these kinds of queries (let's call them "orthogonal LIMIT per resource") relevant enough?
 2) If yes, which way to go? (it seems there'd be at least two extensions of the current subquery mechanism on the table to allow that)  


> >> and not legal SQL :)
> >
> > Not sure what you mean here? I tried out my SQL query in SQLite and it behaved as intended
> OK, the table rename without AS, combined with use of uppercase for table names threw me.
> - Steve
> --
> Steve Harris, CTO, Garlik Limited
> 1-3 Halford Road, Richmond, TW10 6AW, UK
> +44 20 8439 8203  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, 13 August 2010 12:17:27 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:01:01 UTC