Skip to content

Commit 826c5d9

Browse files
authored
Merge pull request #132 from w3c/Issue131
More accurate definition of the Group operator
2 parents 580f1f7 + dcfccc7 commit 826c5d9

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

spec/index.html

+30-23
Original file line numberDiff line numberDiff line change
@@ -9533,8 +9533,6 @@ <h3>SPARQL Algebra</h3>
95339533
<p><a href="#defn_Multiplicity">multiplicity</a>( μ | ToMultiSet(Ψ) ) =
95349534
<a href="#defn_Multiplicity">multiplicity</a>( μ | Ψ )</p>
95359535
</div>
9536-
<p>ListEval is a function which is used to evaluate a list of expressions against a
9537-
solution and return a list of the resulting values.</p>
95389536
<div class="defn">
95399537
<div id="defn_algToMultiset">
95409538
<b>Definition: ToMultiset</b>
@@ -9558,21 +9556,41 @@ <h4>Aggregate Algebra</h4>
95589556
<div id="defn_algGroup">
95599557
<b>Definition: Group</b>
95609558
</div>
9561-
<p>Group evaluates a list of expressions against a solution sequence Ψ, producing a
9559+
<p>Group evaluates a list of expressions against a solution sequence <var>Ψ</var>, producing a
95629560
partial function from keys to solution sequences.</p>
9563-
<p>Group(exprlist, Ψ) = { ListEval(exprlist, μ) → [ μ' | μ' in Ψ, ListEval(exprlist, μ)
9564-
= ListEval(exprlist, μ') ] | μ in Ψ }</p>
9561+
<p>Group(<var>exprlist</var>, <var>Ψ</var>) = {
9562+
<a href="#defn_ListEval">ListEval</a>(<var>exprlist</var>, <var>μ</var>)
9563+
→ [ <var>μ'</var> | <var>μ'</var> in <var>Ψ</var> such that
9564+
<a href="#defn_ListEval">ListEval</a>(<var>exprlist</var>, <var>μ'</var>) and
9565+
<a href="#defn_ListEval">ListEval</a>(<var>exprlist</var>, <var>μ</var>)
9566+
are the same ] | <var>μ</var> in <var>Ψ</var> },</p>
9567+
<p>where two lists <var>L</var> and <var>L'</var> (as produced by
9568+
the <a href="#defn_ListEval">ListEval</a> function) are considered
9569+
the same iff they have the same number of elements and, for every
9570+
position&nbsp;<var>k</var> within the two lists, either of the
9571+
following two conditions is true:</p>
9572+
<ul>
9573+
<li>the element at the <var>k</var>-th position of
9574+
<var>L</var> is an RDF term; the element at the <var>k</var>-th
9575+
position of <var>L'</var> is also an RDF term; and these two
9576+
RDF terms are the <a href="#func-sameTerm">same term</a></li>
9577+
<li>the element at the <var>k</var>-th position of <var>L</var>
9578+
is an error, and the element at the <var>k</var>-th position of
9579+
<var>L'</var> is also an error</li>
9580+
</ul>
95659581
</div>
95669582
<div class="defn">
9567-
<p><b>Definition: ListEval</b></p>
9583+
<p><b>Definition: <span id="defn_ListEval">ListEval</span></b></p>
95689584
<p>ListEval((expr<sub>1</sub>, ..., expr<sub>n</sub>), μ) returns a list
95699585
(e<sub>1</sub>, ..., e<sub>n</sub>), where e<sub>i</sub> = expr<sub>i</sub>(μ) or
95709586
error.</p>
95719587
<p>ListEval retains errors resulting from the evaluation of the list elements.</p>
95729588
</div>
9573-
<p>Note that, although the result of a ListEval can be an error, and errors may be used
9589+
<p>Note that, although the result of <a href="#defn_ListEval">ListEval</a>
9590+
may contain errors, and errors may be used
95749591
to group, solutions containing error values are removed at projection time.</p>
9575-
<p>ListEval((unbound), μ) = (error), as the evaluation of an unbound expression is an
9592+
<p>Note also that the result of <a href="#defn_ListEval">ListEval</a>((unbound), <var>μ</var>)
9593+
is the list (error), as the evaluation of an unbound expression is an
95769594
error.</p>
95779595
<p>Aggregation, a function which calculates a scalar value as an output of the aggregate
95789596
expression. It is used in the SELECT clause, the HAVING evaluation process, and in ORDER
@@ -9594,30 +9612,19 @@ <h4>Aggregate Algebra</h4>
95949612
&nbsp;&nbsp;&nbsp;= { (key, F(Ψ)) | key → Ψ in { key<sub>1</sub>→Ψ<sub>1</sub>, ...,
95959613
key<sub>m</sub>→Ψ<sub>m</sub> } }</p>
95969614
<p>where<br>
9597-
&nbsp;&nbsp;M(Ψ) = [ ListEval(exprlist, μ) | μ in Ψ ]<br>
9615+
&nbsp;&nbsp;M(<var>Ψ</var>) = [ <a href="#defn_ListEval">ListEval</a>(exprlist, <var>μ</var>) | <var>μ</var> in <var>Ψ</var> ]<br>
95989616
&nbsp;&nbsp;F(Ψ) = func(M(Ψ), scalarvals), for non-<code>DISTINCT</code><br>
95999617
&nbsp;&nbsp;F(Ψ) = func(Dedup(M(Ψ)), scalarvals), for <code>DISTINCT</code></p>
96009618
<p>with Dedup(M(Ψ)) being an order-preserving, duplicate-free version of the sequence M(Ψ); that is, Dedup(M(Ψ)) is a sequence of lists that has the following four properties
96019619
(where each such list in this sequence may contain RDF terms and
9602-
errors, as it is produced by the ListEval function).</p>
9620+
errors, as it is produced by the <a href="#defn_ListEval">ListEval</a> function).</p>
96039621
<ol>
96049622
<li>For every list&nbsp;<var>L</var> in M(Ψ) there exists a
96059623
list&nbsp;<var>L'</var> in Dedup(M(Ψ)) such that <var>L</var>
96069624
and <var>L'</var> are the same,
96079625
where two lists <var>L</var> and <var>L'</var> from M(Ψ) are
9608-
considered the same iff they have the same number of elements
9609-
and, for every position&nbsp;<var>k</var> within the two lists,
9610-
any of the following two conditions is true:
9611-
<ul>
9612-
<li>either the element at the <var>k</var>-th position of
9613-
<var>L</var> is an RDF term, the element at the <var>k</var>-th
9614-
position of <var>L'</var> is also an RDF term, and these two
9615-
RDF terms are the <a href="#func-sameTerm">same term</a>;</li>
9616-
<li>or the element at the <var>k</var>-th position of <var>L</var>
9617-
is an error and the element at the <var>k</var>-th position of
9618-
<var>L'</var> is also an error.</li>
9619-
</ul>
9620-
</li>
9626+
considered the same as specified in the definition of the
9627+
<a href="#defn_algGroup">Group operator</a>.</li>
96219628
<li>For every list&nbsp;<var>L</var> in Dedup(M(Ψ)) there exists
96229629
a list&nbsp;<var>L'</var> in M(Ψ) such that <var>L</var> and
96239630
<var>L'</var> are the same.</li>

0 commit comments

Comments
 (0)