W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > April to June 2005

Re: Optional WHERE and WHERE {}

From: Dave Beckett <dave.beckett@bristol.ac.uk>
Date: Mon, 25 Apr 2005 10:36:09 +0100
To: "Seaborne, Andy" <andy.seaborne@hp.com>
Cc: 'RDF Data Access Working Group' <public-rdf-dawg@w3.org>
Message-ID: <20050425103609.4faba73d@hoth.ilrt.bris.ac.uk>

On Thu, 21 Apr 2005 21:03:28 +0100, "Seaborne, Andy" <andy.seaborne@hp.com> wrote:

> Dave Beckett wrote:
> > Question: Is the WHERE {...} structure optional in sparql?
> > 
> > The grammar says yes and lookin in the WD I can see it's given as an
> > example with ASK,
> > 
> > So whereas CONSTRUCT, DESCRIBE and SELECT are all given examples
> > requiring WHERE { .... },  ASK has the format ASK { ...} and no WHERE.
> > Possibly ASK WHERE { ... } would be more consistent.
> 
> [1] Query  	  ::=    Prolog
>                          ( SelectClause | ConstructClause |
>                            DescribeClause | AskClause )
>                          DatasetClause?
>                          WhereClause?
>                          OrderClause?
>                          LimitClause?
>                          OffsetClause?
> 
> so the whole clause is optional and not related to which kind of query it is.

Not the whole clause, as the ( ... ) bit is required.

I've called it ReportFormat in my yacc grammar after some earlier SPARQL draft
grammar, as I needed to rewrite it anyway to remove the multiple grammar clauses
in your grammar.

> e.g. DESCRIBE <uri>
> CONSTRUCT { :a :b :c }
> 
> and also:
> 
> [13] WhereClause  	  ::=    	'where'? GraphPattern
> 
> so the WHERE keyword is optional.

!!!

This is very odd to me.  I am only going to ever teach that WHERE is required
as it is a oddity to the language style of KEYWORD {block} everywhere else.

Just because something can be omitted without ambiguity, it doesn't need to be
allowed.  Are you going to allow BY to be omitted from ORDER BY ? :)


> These are both legal.
> 
> SELECT * WHERE { ?x ?y ?z }
> SELECT * { ?x ?y ?z }

Abutting of punctiation terms '*' and {' should be avoided in my opinion, except
where needed (turtle ;, etc. do need this).  Something that looks like an arithmetic
operator '*' is particular tricky also and prevents quick reading and understanding
of queries.

> 
> We could have different rules for presence/absence for each query type but at 
> the moment it is symmetrical.
> 
> > 
> > So thinking further, what does WHERE with an empty graph pattern {}
> > mean?  I discussed this with EricP in Italy and we think it's the
> > same as query succeding and returning 1 result, and it's what Algae2
> > does.
> 
> Yes - it's a graph pattern that matches any graph.

Is this written down somewhere in the WD?  More clearly it needs to say
it returns 1 match only for any graph, not returns infinite matches of any graph.

> 
> > 
> > Going through the query verbs:
> > 
> > 1. SELECT * WHERE {}
> >   returns 1 result[row] with no bindings
> > 
> > 2. CONSTRUCT { :a :b :c } WHERE {}
> >   returns the graph { :a :b :c}
> > 
> > 3. ASK {}
> >   returns true
> > 
> > 4. DESCRIBE <uri> WHERE {}
> >   Well nobody can tell what it returns :)
> >   but it's probably the same as DESCRIBE <uri> for all cases.
> > 
> > and if WHERE {} is the same as omitting it, then the queries below
> > return the same results as the above:
> > 
> > 1a. SELECT *
> > 2a. CONSTRUCT { :a :b :c }
> > 3a. ASK
> > 4a. DESCRIBE <uri>
> >   -- this one's already in the spec

So the tests I gave were all correct?

Dave
Received on Monday, 25 April 2005 09:40:09 GMT

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