- From: Andy Seaborne <andy.seaborne@talis.com>
- Date: Tue, 17 Nov 2009 08:59:50 +0000
- To: Steve Harris <steve.harris@garlik.com>
- CC: "public-rdf-dawg@w3.org Group" <public-rdf-dawg@w3.org>
On 16/11/2009 20:35, Steve Harris wrote: > On 16 Nov 2009, at 20:14, Andy Seaborne wrote: > ... >>> ?x = :alice, ?bestDay = 12 >>> ?x = :bob, ?bestDay = 8 >>> [no row for :carol because we can't return "unbound"/null from >>> MAX(?sales)] >>> >> >> Would this work? >> >> SELECT ?x ( TRY(MAX(?sales), -1) AS ?bestDay) >> >> or other choice of marker for no value. > > Yes, in this case, but it's a pretty poor substitute. > > I wonder if there's some wording where unbound expressions can be > projected, it seems a little odd that SELECT ?sales produces rows, > whereas SELECT COALESCE(?sales) doesn't. > > Probably if you chase this deep enough though you end up changing SPARQL > 1.0 results :( I guess we should have bitten the bullet and gone with a > tri-value logic to start with. > > - Steve > > PS I really don't like TRY() as a name, though I can see the logic in it. > The core of the issue is touching ?sales at all in an expression context. COALESCE is merely invoking a value context. SELECT ?x SELECT (?x AS ?y) SELECT (?x+1 AS ?y) If we have "SELECT (expr AS ?y)" then (?x AS ?y) has ?x in an expression context requiring a value. In the second and third cases, ?x is evaluated and if there is an error, we need to decide what to do. At F2F2, the consensus was that type errors in project are eliminated - I've been reading that as SELECT xsd:integer("squirrel") {} has no rows. (this part of the chat seems to have started with errors in aggregates and I may be reading the point out of context.) SPARQL only has we only have one kind of error and anyway choosing different actions based on different error types will get tricky because one error may lead to another. This is where the fact relational algebra rename is just a rename (no expressions, it changes the name of a column) makes a difference here. We could special case the translation to the SPARQL algebra: SELECT ?x => project((?x), ....) SELECT (?x AS ?y) => project((?y), rename(?x as ?y) ....)) SELECT (?x+1 AS ?y) => project((?y), extend(?x+1 as ?y) ....)) Andy
Received on Tuesday, 17 November 2009 08:59:59 UTC