W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > January to March 2011

Re: Proposed: SPARQL grammar is complete as-is

From: Eric Prud'hommeaux <eric@w3.org>
Date: Mon, 10 Jan 2011 22:55:11 -0500
To: Andy Seaborne <andy.seaborne@epimorphics.com>
Cc: SPARQL Working Group <public-rdf-dawg@w3.org>
Message-ID: <20110111035510.GA15572@w3.org>
* Eric Prud'hommeaux <eric@w3.org> [2011-01-04 22:43-0500]
> * Andy Seaborne <andy.seaborne@epimorphics.com> [2011-01-04 13:01+0000]
> > 
> > 
> > On 03/01/11 17:16, Eric Prud'hommeaux wrote:
> > >+
> > >I like using BINDINGs in subselects for getting my head around (i.e.
> > >debugging) aggregate queries as it puts the pre-aggregated result set
> > >directly in my face. I use this for didactic and testing purposes:
> > >   http://swobjects.svn.sourceforge.net/viewvc/swobjects/branches/sparql11/tests/sparql11/groupBy-f-having-f.rq?revision=1264&view=markup
> > 
> > More generally, inline data tables - i.e. the ability to put data
> > into a query directly.  There are some ways to this -
> > BINDINGS+SubSELECT but also anywhere AS is used can be combined with
> > UNION to produce inline data.  The latter may be very verbose :-)
> 
> true, this validates:
> SELECT ?a (COUNT(?b) AS ?d) WHERE {
>        { BIND (1 AS ?a) BIND (2 AS ?b) BIND (3 AS ?c) }
>  UNION { BIND (4 AS ?a) BIND (5 AS ?b) BIND (6 AS ?c) }
> } GROUP BY ?c
> 
> 
> > A more consistent approach might be:
> > 
> >    TABLE ?a ?b ?c { (1 2 3) (4 5 6) }
> > 
> > to put anywhere in graph pattern.
> > 
> > (not a proposal for this version of the spec)

Thanks for sticking a BindingsClause on ASK CONSTRUCT and DESCRIBE
(I've updated yacker). <http://www.w3.org/mid/20110103171603.GB23618@w3.org>
proposed some reasons why a BindingsClause on a subselect was useful
for federation. I agree that the above "TABLE" syntax would work
(though it would require special code when serializing subselects
vs. top-level queries), but see that you're not proposing it
either. To that end, I'd like SubSelects to have a BindingsClause:

-SubSelect      ::= SelectClause WhereClause SolutionModifier
+SubSelect      ::= SelectClause WhereClause SolutionModifier BindingsClause?

I'd also like to move the opt-ness out of the BindingsClause
production and into the productions that reference it, e.g.

-Query          ::= Prologue ( SelectQuery | ConstructQuery | DescribeQuery | AskQuery ) BindingsClause
+Query          ::= Prologue ( SelectQuery | ConstructQuery | DescribeQuery | AskQuery ) BindingsClause?
-BindingsClause ::= ( 'BINDINGS' Var* '{' ( '(' BindingValue+ ')' | NIL )* '}' )?
+BindingsClause ::= 'BINDINGS' Var* '{' ( '(' BindingValue+ ')' | NIL )* '}'

This will make it easier for those who wish to extend the grammar to
use the production, as in your TABLE example above:

-GraphPatternNotTriples     ::= GroupOrUnionGraphPattern | OptionalGraphPattern | MinusGraphPattern | GraphGraphPattern | ServiceGraphPattern | Filter | Bind
+GraphPatternNotTriples     ::= GroupOrUnionGraphPattern | OptionalGraphPattern | MinusGraphPattern | GraphGraphPattern | ServiceGraphPattern | Filter | Bind | BindingsClause
(not a proposal, just an example)

> Just for yucks, I tried:
>   GraphPatternNotTriples ::= GroupOrUnionGraphPattern
> 			   | OptionalGraphPattern
> 			   | MinusGraphPattern
> 			   | GraphGraphPattern
> 			   | ServiceGraphPattern
> 			   | Filter
> 			   | Bind
> 			   | "BINDINGS" Var* "{" ( "(" BindingValue+ ")" | NIL )* "}"¹
> 
> and got no reduce/reuse/recycle conflicts.
> 
>   http://www.w3.org/2005/01/yacker?name=SPARQL_11&replace=1&lang=perl#prod-SPARQL_11-GraphPatternNotTriples
> 
> e.g. http://www.w3.org/2005/01/yacker/uploads/SPARQL_11?lang=perl&text=SELECT+%3Fa+%28COUNT%28%3Fb%29+AS+%3Fd%29+WHERE+{%0D%0A++BINDINGS+%3Fa+%3Fb+%3Fc+{+%281+2+3%29+%284+5+6%29+}%0D%0A}+GROUP+BY+%3Fc&action=validate+text#language
> 
> ¹ This is the same as the current BindingsClause except that
>   the BindingsClause is all optional.
> 
> 
> > 	Andy
> 
> -- 
> -ericP

-- 
-ericP
Received on Tuesday, 11 January 2011 03:55:48 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:45 GMT