({{, SPARQLEvaluation["name"] 
represents the built-in SPARQL function with the specified name, to be evaluated during SPARQL graph pattern matching.}, {, SPARQLEvaluation[f]
represents the arbitrary function f.}})

OpenersNotesSection(Spacer1)Details

SPARQLEvaluation[…] can be used in filters, select expressions and aggregates.

Possible built-in SPARQL functions include:

Possible build-in SPARQL functions on RDF terms include:

Possible build-in SPARQL functions on strings include:

Possible build-in SPARQL functions on numbers include:

Possible build-in SPARQL functions on dates and times include:

Possible build-in SPARQL hash functions include:

Possible built-in SPARQL aggregate functions include:

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Needs["GraphStore`"]

Person data:

foaf[s_]:=IRI["http://xmlns.com/foaf/0.1/"<>s];

personData=RDFStore[{
RDFTriple[RDFBlankNode["a"],foaf["firstName"],"Till"],
RDFTriple[RDFBlankNode["a"],foaf["surname"],"Schneider"],
RDFTriple[RDFBlankNode["b"],foaf["firstName"],"Eva"],
RDFTriple[RDFBlankNode["b"],foaf["surname"],"Baumgärtner"],
RDFTriple[RDFBlankNode["c"],foaf["firstName"],"Hans"]
}];

Construct the name from first and last name:

personData//SPARQLSelect[{
RDFTriple[SPARQLVariable["x"],foaf["firstName"],SPARQLVariable["first"]],
RDFTriple[SPARQLVariable["x"],foaf["surname"],SPARQLVariable["last"]]
}->{"name"->SPARQLEvaluation["CONCAT"][SPARQLVariable["first"]," ",SPARQLVariable["last"]]}]

Count the people for which the first name is known:

personData//SPARQLQuery[
SPARQLSelect[RDFTriple[SPARQLVariable["x"],foaf["firstName"],SPARQLVariable["first"]]]/*
SPARQLAggregate["count"->SPARQLEvaluation["COUNT"][]]
]

OpenersExampleSection2(Spacer1)Possible Issues  (1)

Needs["GraphStore`"]

General functions can't be exported as SPARQL string:

ExportString[
SPARQLSelect[RDFTriple[SPARQLVariable["x"],SPARQLVariable["y"],SPARQLVariable["z"]]->{"result"->SPARQLEvaluation[f][SPARQLVariable["z"]]}],
"SPARQLQuery"
]

Use a SPARQL built-in function instead:

ExportString[
SPARQLSelect[RDFTriple[SPARQLVariable["x"],SPARQLVariable["y"],SPARQLVariable["z"]]->{"result"->SPARQLEvaluation["STRLEN"][SPARQLVariable["z"]]}],
"SPARQLQuery"
]

Certain WL functions are also supported:

ExportString[
SPARQLSelect[RDFTriple[SPARQLVariable["x"],SPARQLVariable["y"],SPARQLVariable["z"]]->{"result"->SPARQLEvaluation[StringLength][SPARQLVariable["z"]]}],
"SPARQLQuery"
]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(PackageLink[SPARQLSelect, paclet:GraphStore/ref/SPARQLSelect, GraphStore Package Symbol])  ▪  (PackageLink[SPARQLAggregate, paclet:GraphStore/ref/SPARQLAggregate, GraphStore Package Symbol])  ▪  (PackageLink[RDFStore, paclet:GraphStore/ref/RDFStore, GraphStore Package Symbol])  ▪  (PackageLink[SPARQLExecute, paclet:GraphStore/ref/SPARQLExecute, GraphStore Package Symbol])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Querying RDF Stores Using SPARQL, paclet:GraphStore/guide/SPARQLQuery])}})}})