Symbolic SPARQL: Import and Export
Version 12 adds support for SPARQL, the query language for RDF (Resource Description Framework). Support comes in two flavors: Query strings and a symbolic representation of the whole query language—both can be used interchangeably, whatever better suits a particular use case. While query strings are easy to type, the symbolic representation allows writing elegant and concise programs that generate queries that depend, say, on user input or the result of a computation.
This example shows how to convert between both query representations. Start with an example query from Wikidata, the "number of humans in Wikidata".
Store the query string in a variable.
Now use the "SPARQLQuery" importer to obtain the symbolic equivalent of this query.
The result is the SPARQLQuery operator containing a SPARQLSelect query, right-composed (/*) with a SPARQLAggregate.
Both query forms can be used interchangeably to execute the query. Try both on the Wikidata SPARQL endpoint.
You can also go the other direction: Export the symbolic query to a query string.