W3C home > Mailing lists > Public > public-rdf-dawg-comments@w3.org > August 2011

Questions concerning 11.7 (Aggregate Example (with errors))

From: Bryan Thompson <bryan@systap.com>
Date: Mon, 1 Aug 2011 08:15:11 -0500
To: "public-rdf-dawg-comments@w3.org" <public-rdf-dawg-comments@w3.org>
Message-ID: <DE10B00CCE0DC54883734F3060AC9ED4538CCFC917@AUSP01VMBX06.collaborationhost.net>

I am trying to put together some unit tests for error handling for aggregates.  Based on the example below it seems that an error within an aggregate function (such as SUM or AVG) is NOT trapped by the function (which would cause the specific solution to be dropped by that function), but rather causes the evaluation of that function for the group to fail such that no value is bound for that function for that group.  Is this the correct reading?  Also, per the example, the failure of one aggregate for a group does not cause the group to be dropped, just that aggregate, correct?

Also, if the test were modified to such that ?c could be computed while ?avg still produced an error, I presume that ?c would become bound for the group.  For example, consider if the source of the error was a Literal having numeric data but not explicitly typed as some xsd numeric datatype rather than a blank node.  In this case, one of the aggregates might be written to parse the literal, returning its numeric value.  Under those circumstances, I presume that ?c would become bound but that ?avg would not.

One more twist to consider.  What if there is a HAVING clause and it encounters the same error?  I assume that it should fail the group in which the error was encountered, but not the entire query.  E.g., HAVING SUM(?p) > 0 in the example below.  That would trip on the same error which is tripping up AVG(?p).

Any clarification in this matters is appreciated.

11.7 Aggregate Example (with errors)


@prefix : <http://example.com/data/#> .

:x :p 1, 2, 3, 4 .
:y :p 1, _:b2, 3, 4 .
:z :p 1.0, 2.0, 3.0, 4 .


PREFIX : <http://example.com/data/#>
SELECT ?g (AVG(?p) AS ?avg) ((MIN(?p) + MAX(?p)) / 2 AS ?c)
  ?g :p ?p .


g       avg     c
<http://example.com/data/#x>    2.5     2.5
<http://example.com/data/#z>    2.5     2.5

Note that the bindings for the :y group is not included in the results as the evaluation of Avg({1, _:b2, 3, 4}), and (_:b2 + 4) / 2 is an error, removing the bindings from the solution.
Received on Monday, 1 August 2011 13:17:02 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:52:11 UTC