Re: Review SPARQL Query 1.1, Section 18 (algebra)

Steve,
I have additional comments regarding the algebra section and
aggregates and I comment on Andy's example below.

The def. of Sample says:
literal   Sample(multiset M)
Why literal? Is that a copy & past error because most other aggregtes
return a literal? Sample should return an RDF-Term I would say.

Under Definition: ListEval
Note that, although the result of a ListEval can be an error, and
errors may be used to group, solutions containing error values are
removed at projection time.

I actually can't see where that is done at projection time, it happens
in AggregateJoin.

On 17 March 2011 11:22, Andy Seaborne <andy.seaborne@epimorphics.com> wrote:
[snip]
> Also, time permitting, adding some text
> about
> SELECT ?x {} GROUP BY ?x is
> is in evaluation:
> SELECT (sample(?x) AS ?x) {} GROUP BY ?x ## but that's illegal syntax
> would be good.

Is it? I get
SELECT agg1 {} GROUP BY ?x
with the introduced SAMPLE being only visible in the algebra object.

Algebra translation says:
For each expression E in SELECT and each HAVING(E) in Q
   If E does not contain an aggregate
      Replace E with Sample(E) in Q -> Gives SELECT SAMPLE(?x) ...
   For each variable V appearing outside of an aggregate
      Replace V with Sample(V) in Q
   For each aggregate X(args ; scalarvals) now in E
      # note scalarvals may be omitted, then it's equivalent to the empty set
      Ai := Aggregation(args, X, scalarvals, G) -> Here I have the SAMPLE
      Replace X(...) with aggi in Q -> gives SELECT agg_1 ...

I don't get (agg1 AS ?x) though.

The whole algebra obj I get is:
Project(AggregateJoin(Aggregation((?x), SAMPLE, {}, Group((?x),
Bgp(Z)))), {agg1})
Bgp(Z) evaluates to μ_0 (identity).
Group((?x), μ_0) evaluates to
{ (err)->{μ_0} }
Aggregation(...) to
{ (err) -> err }
Now we have to evluate AggregateJoin(...) as this:
eval(D(G), AggregateJoin(A)) = { (aggi, eval(D(G), Ai)) | Ai in A,
eval(D(G), Ai) is not an error }
{ (agg_1, { ((err), err) } ) }
This is what I get when I follow the definition, because it just puts
the eval(D(G), Ai) in for agg1, but that's not what I want. I want
just err (or possibly leave that out as an error instead of at
projection time, so I need something like:
Definition: Evaluation of AggregateJoin
Write A = (A1, A2, ...) where Ai = Aggregation(exprListi, funci, scalarvarsi, P)
Let AEi = eval(D(G), Ai).
eval(D(G), AggregateJoin(A)) =
{ { aggi -> AEi(k) | 1 <= i <= n and AEi(k) is not an error } | k in
dom(AEi) for 1 <= i <= n }

If we compare the exisiting def. for the example in 11.6:
eval(D(G), A1) = { (1,3) → 5, (7,9) → 11 }
eval(D(G), A2) = { (1,3) → 6, (7,9) → 12 }
you want
AggregateJoin(A1, A2) gives
{ (agg1, { (1,3) → 5, (7,9) → 11 }),  (agg2, { (1,3) → 6, (7,9) → 12 }) }
the new def. produces two mappings, one for each k in {(1,3), (7,9)}
{ { agg1 -> 5, agg2 -> 6 }
  { agg1 -> 11, agg2 -> 12 } }
as required. In case of errors, just the agg_i for a k that has an
error value is unbound, which is what I think you want.
Going back to Andy's example, I would get
{ {agg1 -> err} }, which actually means that the agg1 binding is
omitted, so I get just { {} } in fact.
If I now project, the projection has no effect and I get { {} } as
result, i.e., one result with an empty solution mapping.

Birte

>        Andy
>
>
>
>



-- 
Dr. Birte Glimm, Room 309
Computing Laboratory
Parks Road
Oxford
OX1 3QD
United Kingdom
+44 (0)1865 283520

Received on Thursday, 17 March 2011 16:08:31 UTC