Duplicate columns and group keys

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

# Duplicate group by variable
    ?s ?p ?o
} GROUP BY ?s ?s

In result sets: two cases, the same binding duplicated in a row and an 
attempt to provide different bindings (the latter IMHO is an error 
because it's nonsensical in the design).

# Duplicate in result set (XML) - SPARQL 1.0
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
     <variable name="s"/>
     <variable name="p"/>
     <variable name="s"/>
     <variable name="o"/>
       <binding name="s"> <!-- First -->
       <binding name="p">
       <binding name="s">  <!-- Second (here, the same value) -->
       <binding name="o">

# Duplicate in result set (JSON) - SPARQL 1.0
   "head": {
     "vars": [ "s" , "p" , "s" , "o" ]
   } ,
   "results": {
     "bindings": [
         "s": { "type": "uri" , "value": "http://example/s" } , # First
         "p": { "type": "uri" , "value": "http://example/p" } ,
         "s": { "type": "uri" , "value": "http://example/s" } , # Second
         "o": { "type": "uri" , "value": "http://example/o" }


Appendix: JSON and duplicate keys:

The JSON description on json.org does not ban this
An object is an unordered set of name/value pairs.

and RFC 4627
An object is an unordered collection of zero or more name/value
    pairs, where a name is a string and a value is a string, number,
    boolean, null, object, or array.
The names within an object SHOULD be unique.

which means ("x", 1) ("x", 2) is a legal as a set of two different pairs 
and ("x", 1) , ("x", 1) is a set of one pair but an unordered list or 
bag of two pairs.

The org.json Java implementation throws an exception.

Received on Thursday, 30 September 2010 10:58:50 UTC