4

Complex SPARQL queries are laborious to construct, and are difficult to read. Is there is way to `include' sub-queries in SPARQL, such as using an "include queryX" line, that would save one from writing out repetitive simple queries in separate more complex queries each time?

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
Rob Stewart
  • 1,812
  • 1
  • 12
  • 25
  • 3
    Nothing built in to the spec. Depending on the SPARQL tool you're using, there might be support for defining templates, adding placeholders, parameters, etc. but any such feature would be non-standard. – Alex Nov 02 '12 at 16:08
  • Blazegraph supports named subqueries: https://wiki.blazegraph.com/wiki/index.php/NamedSubquery – Stanislav Kralin Oct 13 '17 at 15:53

1 Answers1

0

The SPARQL FAQ mentions the following possibility:

A very limited form of subqueries can be accomplished with SPARQL engines that will perform HTTP GETs upon graphs named in FROM or FROM NAMED clauses by creating a URL consisting of an embedded SPARQL CONSTRUCT query submitted to a SPARQL endpoint and supplying this URL as part of the RDF dataset being queried. In practice, this technique is often inefficient and is subject to possible URL-maximum-length restrictions of the involved software.

The W3C wiki mentions some other possible workarounds as well.

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265