Re: Duplicate columns and group keys

On 30/09/10 13:51, Lee Feigenbaum wrote:
> On 9/30/2010 6:57 AM, Andy Seaborne wrote:
>> Following a jena-dev question, I wondered what do implementations do
>> with the following?
>>
>> # Duplicate select variable - SPARQL 1.0
>> SELECT ?s ?s ?p ?o
>> {
>> ?s ?p ?o
>> }
>
> Glitter returns the ?s "column" twice, including listing it twice in the
> <head> of the SRX.

ARQ suppresses the duplicate although that's (now) controlled by a flag 
and the ARQ test suite passes with either setting.  I did have to fix 
the result set XML readers to cope; the JSON parser handles this at the 
JSON level.

The tricky case is

SELECT (?x+?y AS ?z) (?2*?x AS ?z)

which is a static error in ARQ
but this is easier:

SELECT (?x+?y AS ?z) ?z

so of the 4 cases, ARQ only allows only allows

SELECT ?z ?z

and normally it means one variable but switching to two (should!) work.

The SPARQL 1.1 text needs clarification.

>
>> # Duplicate group by variable
>> SELECT ?s
>> {
>> ?s ?p ?o
>> } GROUP BY ?s ?s
>
> I haven't tried this, but I'd expect this just works the same as GROUP
> BY ?s - is there a subtlety here that I'm missing?

My reading of the defn of aggregation is that there is a key for the 
group which is the pair (?s, ?s) not simple ?s (the group key is 
ExprList - an expression list).  That means you'll get exactly the same 
answers although the route to getting them is slightly different but 
it's not observable.

 Andy

Received on Thursday, 30 September 2010 18:20:55 UTC