SPARQLOptional[patt]
represents part of a pattern that does not need to match in order for the whole pattern to match.
SPARQLOptional
SPARQLOptional[patt]
represents part of a pattern that does not need to match in order for the whole pattern to match.
Details and Options
- In SPARQLOptional[patt], patt can take the same form as in SPARQLSelect[patt].
Examples
Basic Examples (1)
Needs["GraphStore`"]schema[s_] := URL["http://schema.org/" <> s];
ex[s_] := URL["http://example.org/" <> s];fruitGraph = RDFStore[{
RDFTriple[ex["banana"], schema["color"], "yellow"],
RDFTriple[ex["strawberry"], schema["color"], "red"],
RDFTriple[ex["strawberry"], ex["shape"], ex["round"]]
}];Find the color and optionally the shape of fruits:
fruitGraph//SPARQLSelect[{
RDFTriple[SPARQLVariable["fruit"], schema["color"], SPARQLVariable["color"]],
SPARQLOptional[RDFTriple[SPARQLVariable["fruit"], ex["shape"], SPARQLVariable["shape"]]]
}]See Also
Related Guides
Text
Wolfram Research (2019), SPARQLOptional, Wolfram Language function, https://reference.wolfram.com/language/GraphStore/ref/SPARQLOptional.html.
CMS
Wolfram Language. 2019. "SPARQLOptional." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/GraphStore/ref/SPARQLOptional.html.
APA
Wolfram Language. (2019). SPARQLOptional. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/GraphStore/ref/SPARQLOptional.html
BibTeX
@misc{reference.wolfram_2026_sparqloptional, author="Wolfram Research", title="{SPARQLOptional}", year="2019", howpublished="\url{https://reference.wolfram.com/language/GraphStore/ref/SPARQLOptional.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_sparqloptional, organization={Wolfram Research}, title={SPARQLOptional}, year={2019}, url={https://reference.wolfram.com/language/GraphStore/ref/SPARQLOptional.html}, note=[Accessed: 15-June-2026]}