Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2960,10 +2960,18 @@ <h3>HAVING</h3>
</section>
<section id="aggregateRestrictions">
<h3>Aggregate Projection Restrictions</h3>
<p>In a query level which uses aggregates, only expressions consisting of aggregates and
constants may be projected, with one exception. When <code>GROUP BY</code> is given with one
or more simple expressions consisting of just a variable, those variables may be projected
from the level.</p>
<p>In a query level which uses grouping (either by the explicit use of a <code>GROUP BY</code> clause
or through the use of aggregates in projection, <code>HAVING</code>, or <code>ORDER BY</code> clauses),
every occurrence of a variable that appears in projection or SELECT expressions of that query level
MUST satisfy one of the following conditions:</p>
Comment on lines +2963 to +2966

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p>In a query level which uses grouping (either by the explicit use of a <code>GROUP BY</code> clause
or through the use of aggregates in projection, <code>HAVING</code>, or <code>ORDER BY</code> clauses),
every occurrence of a variable that appears in projection or SELECT expressions of that query level
MUST satisfy one of the following conditions:</p>
<p>In a query level which uses grouping (either by the explicit use of a <code>GROUP BY</code> clause,
or by the use of an aggregate in projection, a <code>HAVING</code> clause, or an <code>ORDER BY</code> clause),
every occurrence of a variable that appears in a projection or a SELECT expression of that query level
MUST satisfy one of the following conditions:</p>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TallTed – This has already been merged. A new PR is probably the best approach for this change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to issue #386 and pr #387

<ul>
<li>the variable, <var>V</var>, appears as a named <code>GROUP BY</code> variable (with the corresponding <code>GROUP BY</code> expression consisting of just the variable <var>V</var>, or having the form <code>(expr AS <var>V</var>)</code>)</li>
<li>the variable appears as part of a sub-expression within the SELECT expression and this sub-expression is used as an argument to an aggregate (e.g., <code>MIN(?v)</code> or <code>AVG(?v+2)</code>)
</li>
<li>the variable is introduced by an earlier SELECT expression in the same SELECT clause</li>
Comment thread
kasei marked this conversation as resolved.
</ul>
<p>If such a variable occurrence does not satisfy one of these conditions, the query is syntactically invalid.</p>

<p>For example, the following query is legal as ?x is given as a <code>GROUP BY</code>
term.</p>
<pre class="query nohighlight">
Expand All @@ -2974,12 +2982,11 @@ <h3>Aggregate Projection Restrictions</h3>
?x :q ?z .
} GROUP BY ?x (STR(?z))
</pre>
<p>Note that it would not be legal to project <code>STR(?z)</code> as this is not a simple
variable expression. However, with <code>GROUP BY (STR(?z) AS ?strZ)</code> it would be
<p>Note that it would not be legal to project <code>STR(?z)</code> as this expression is neither a simple variable,
nor a named <code>GROUP BY</code> expression. However, with <code>GROUP BY ?x (STR(?z) AS ?strZ)</code> it would be
possible to project <code>?strZ</code>.</p>
<p>Other expressions, not using <code>GROUP BY</code> variables, or aggregates may have
non-deterministic values projected from their groups using the <code>SAMPLE</code>
aggregate.</p>
<p>Other expressions which use variables not satisfying the above conditions may be
projected from their groups using the <code>SAMPLE</code> aggregate.</p>
</section>
<section id="aggregateExample2">
<h3>Aggregate Example (with errors)</h3>
Expand Down
Loading