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

Re: rq25 aggregate functions

From: Andy Seaborne <andy.seaborne@talis.com>
Date: Mon, 21 Dec 2009 18:07:00 +0000
Message-ID: <4B2FB944.4060804@talis.com>
To: Steve Harris <steve.harris@garlik.com>
CC: SPARQL Working Group <public-rdf-dawg@w3.org>
Steve and I were discussing aggregates on IRC: this is for the record 
because we didn't have time to complete the discussion there and then.

What we both want is that

sum(1, unbound) -> 1

sum(1, 2/0) -> error

i.e skip unbounds in the group but return error on bad expressions.

COALESCE does not help because it treats both as the same.  And does not 
work for min and max which are multi-datatype.

The key text is:

Definition: Aggregation

Any unbound values exp · μ' do not appear in the resulting value multiset

which (my reading) that says evaluate exp on μ' then see if it's unbound.

But the single variable case sum(?x) has an expression of ?x so exp · μ' 
is called on unbound ?x (which is an error) then the test is made to see 
if it's unbound (it's not - it's now error).

We could special-case evaluation of aggregates.  If it's a single 
variable, then return value or unbound.  If it's any other expression 
(including ?x+0), then evaluate as normal, i.e. error.  There are 
otherways for sum (e.g. the value of unbound is always zero) but is 
using the special feature that zero is the identity value for + so does 
not work for other aggregates.


On 20/12/2009 19:59, Steve Harris wrote:
> Hi all,
> I've just added the text on aggregate functions to
> http://www.w3.org/2009/sparql/docs/query-1.1/rq25.xml#aggregateFunctions
> The main new content is a new definition of Aggregation, to match the
> groups intentions for the use of aggregate functions, and definitions
> The notation around “exp · μ'” in Aggregation is questionable, so if
> anyone has a better suggestion I'm all ears.
> I'm hoping to put the definitions for sub-select in rq25 on Monday.
> - Steve
Received on Monday, 21 December 2009 18:07:21 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:00:58 UTC