From: Rob V. <rv...@do...> - 2015-04-09 13:30:28
|
Mark Comments inline: From: Mark D Wood <mar...@ko...> Reply-To: dotNetRDF User Help and Support <dot...@li...> Date: Thursday, 9 April 2015 14:04 To: "dot...@li..." <dot...@li...> Subject: [dotNetRDF-Support] SparqlQueryProcessor > I have the following SPARQL query which Apache Fuseki evaluates just fine, but > which dotNetRDF throws an exception in method ParseInternal in > SparqlQueryParser if I try to parse it locally. > > This query, borrowing from someone’s kind example > <http://stackoverflow.com/questions/11040274/custom-functions-in-sparql-with-t > he-jena-api> on Stack Overflow, computes an average and standard deviation > value using a Jena-specific built-in function. > > PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> > PREFIX sem: <http://ns.kodak.com/sem/1.0/> > PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> > > SELECT ( afn:sqrt( sum( (?fVal - ?ave) * (?fVal - ?ave) ) / (COUNT(?fv) - 1) > ) as ?stddev ) (avg(?fVal) as ?a) > FROM <urn:guid:mdw> > WHERE { > ?pic sem:MyPredicate ?fv . > BIND (xsd:float(?fv ) AS ?fVal) > { > SELECT (AVG(?fVal2) AS ?ave) (COUNT(?fVal2) as ?cnt) WHERE > { > ?pic sem:MyPredicate ?fvi . > BIND (xsd:float(?fvi ) AS ?fVal2) > } > } > } > > The SPARQL 1.1 specification does say in Section 1.1 > > In aggregate queries and sub-queries, variables that appear in the query > pattern, but are not in the GROUP BY clause, can only be projected or used in > select expressions if they are aggregated. The SAMPLE aggregate may be used > for this purpose. For details see the section on Projection Restrictions > <http://www.w3.org/TR/sparql11-query/#aggregateRestrictions> . No this query is valid SPARQL 1.1 our parser is just being overly strict. Since there is no GROUP BY there is an implicit group of all solutions so any result variable is legal > > so it would appear that Fuseki is supporting something here that goes beyond > the standard? (If so, it is a nice extension as otherwise I don’t know how > I’d compute a standard deviation.) No we're just being too strict in this case > > I believe the exception is generated in the following line of code: > > //Check that either there are no Aggregates used or > only Aggregates used > if > (SparqlSpecsHelper.IsSelectQuery(context.Query.QueryType) && > (context.Query.IsAggregate && context.Query.GroupBy == null && > context.Query.Variables.Any(v => v.IsResultVariable && !v.IsAggregate))) > { > thrownewRdfParseException("The Select Query is > invalid since it contains both Aggregates and Variables in the SELECT Clause > but it does not contain a GROUP BY clause"); > } > > Is there a way to get dotNetRDF to pass this query along to Fuseki? I am > using SparqlConnector.Query. Yes: connector.SkipLocalParsing = true; Rob > > Thanks, > -Mark > > > > ------------------------------------------------------------------------------ > BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT Develop your own > process in accordance with the BPMN 2 standard Learn Process modeling best > practices with Bonita BPM through live exercises > http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ > source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF________ > _______________________________________ dotNetRDF-Support mailing list > dot...@li... > https://lists.sourceforge.net/lists/listinfo/dotnetrdf-support |