- From: Steve Harris <steve.harris@garlik.com>
- Date: Thu, 14 Oct 2010 11:32:38 +0100
- To: Andy Seaborne <andy.seaborne@epimorphics.com>
- Cc: SPARQL Working Group <public-rdf-dawg@w3.org>
On 2010-10-14, at 11:06, Andy Seaborne wrote:
> Just checking - this going to be legal, isn't it? It's an idiom that seems natural and people do use it:
>
> SELECT (SAMPLE(?x) AS ?x)
> {
> ... ?x ...
> } GROUP BY ?groupKey
>
It's my intention that it's legal, agreed people do want to do that.
> In other words, can I use ?x as a new variable because the inner one is hidden by the group. It seems a natural thing to write in the SAMPLE case.
>
> From wiki/Potentially_bound it seems the answer is yes. ?x is not potentially bound when used at the point "AS ?x"
>
> The ?x in SAMPLE(?x) is a different ?x because aggregates happen before select expressions in modifier order.
>
> The ordering is:
> # Grouping
> # Aggregates
> # Select expressions
> # Having
> ...
>
> and so
>
> # Aggregates
> ... at this point only GROUP BY vars + aggregates are visible. [1]
> # Select expressions
>
> [1] minor: and so the aggregates are assigned to temporary vars to be renamed in the select expressions? Can't see how else it would work.
I think it all comes out in the wash around AggregateJoin, but wouldn't swear to that. The agg_i identifiers are doing the same thing, I think.
- Steve
--
Steve Harris, CTO, Garlik Limited
1-3 Halford Road, Richmond, TW10 6AW, UK
+44 20 8439 8203 http://www.garlik.com/
Registered in England and Wales 535 7233 VAT # 849 0517 11
Registered office: Thames House, Portsmouth Road, Esher, Surrey, KT10 9AD
Received on Thursday, 14 October 2010 10:33:14 UTC