Design:Project Expression

From SPARQL Working Group
Revision as of 03:38, 29 September 2009 by Lfeigenb (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Definition and scope of feature

We extend the existing SPARQL SELECT patterns to include [PrimaryExpression]. SPARQL1 allows the selection of variables and provides an extensible set of functions and operators (primarily based on XPath). Project Expression inserts the results of a function into a result set.

Status

The open issues are below:

Syntax

This proposal adds PrimaryExpression to the [SELECT pattern].

[5]    	SelectQuery 	   ::=    	"SELECT" (( "DISTINCT" | "REDUCED" ))? ( (( Var | PrimaryExpression "AS" Var ))+ | "*" ) (DatasetClause)* WhereClause SolutionModifier

An [example]:

SELECT ?name STR(?streetNo) AS ?no
WHERE {
  ?who foaf:name ?name ;
       my:streetNo ?streetNo .
}

Survey of syntax forms in deployed systems

Some systems allow optional commas between items in the SELECT clause. The commas can used between each item; for these systems, mixed comma and no comma between items appears is permitted.


  • Glitter
SELECT ?x ?y (?x+?y AS ?z)
  • RDF::Query
SELECT ?x ?y (?x+?y AS ?z)
  • ARQ
SELECT ?x ?y (?x+?y AS ?z)
  • Virtuoso

Optional commas. () required with AS

SELECT ?x ?y (?x+?y) AS ?z
SELECT ?x , ?y , (?x) AS ?z
  • Redland:RASQAL

Optional commas. () required with AS

SELECT ?x ?y (?x+?y) AS z
  • ARC
SELECT ?x ?y count(?a) AS ?z

AS only with aggregates.

  • Sesame

(contributed parser)

SELECT ?x ?y datatype(?a) AS "z"

References

RDF::Query http://cpansearch.perl.org/src/GWILLIAMS/RDF-Query-2.200/lib/RDF/Query/Parser/SPARQLP.pm

Glitter: http://svn.openanzo.org/svn/openanzo/openanzo/trunk/org.openanzo.rdf/grammar/sparql.jj

ARQ: http://jena.svn.sourceforge.net/viewvc/jena/ARQ/trunk/Grammar/arq.jj

RASQAL: http://svn.librdf.org/view/*checkout*/rasqal/trunk/src/sparql_parser.y

ARC2: http://code.semsol.org/source/arc/parsers/ARC2_SPARQLPlusParser.php

Virtuoso: http://docs.openlinksw.com/virtuoso/rdfsparqlimplementationextent.html http://virtuoso.cvs.sourceforge.net/viewvc/*checkout*/virtuoso/virtuoso-opensource/libsrc/Wi/sparql_p.y

Sesame: http://repo.aduna-software.org/svn/org.openrdf/sesame-ext/sparqlplus/trunk/src/main/java/org/openrdf/query/parser/sparqlplus/ast/sparql+.jjt