SPARQLDistinct[]
is a query operator that deletes duplicate solutions.
SPARQLDistinct
SPARQLDistinct[]
is a query operator that deletes duplicate solutions.
Details and Options
- A RightComposition of operators SPARQLSelect[…]/*…/*SPARQLDistinct[]/*… can be used in SPARQLExecute to query a SPARQL endpoint. Composition is also supported.
- SPARQLDistinct[] can be applied to the result of a SPARQLSelect query.
- Solutions are represented as associations.
- SPARQLDistinct[] treats associations that differ only in the order of their keys as the same.
Examples
open all close allBasic Examples (1)
Needs["GraphStore`"]people = GraphStore`RDFStore[{GraphStore`RDFTriple[URL["http://example.org/bobSmith"],
URL["http://xmlns.com/foaf/0.1/name"], "bob"], GraphStore`RDFTriple[
URL["http://example.org/bobTaylor"], URL["http://xmlns.com/foaf/0.1/name"], "bob"],
GraphStore`RDFTriple[URL["http://example.org/annaWatson"], URL["http://xmlns.com/foaf/0.1/name"],
"anna"]}, Association[]];select = SPARQLSelect[RDFTriple[RDFBlankNode[], URL["http://xmlns.com/foaf/0.1/name"], SPARQLVariable["name"]]];people//SPARQLQuery[select /* SPARQLDistinct[]]Count the occurrences of each name:
people//SPARQLQuery[
select /* SPARQLAggregate[
{"name", "count" -> SPARQLEvaluation["count"][]},
SPARQLVariable["name"]
]
]Properties & Relations (1)
Needs["GraphStore`"]The first two associations differ only in the order of their keys:
data = {
<|"x" -> 1, "y" -> "a"|>,
<|"y" -> "a", "x" -> 1|>,
<|"x" -> 2, "y" -> "b"|>
};DeleteDuplicates treats associations with keys in a different order as different:
data//DeleteDuplicatesFor SPARQLDistinct the order of keys does not matter:
data//SPARQLDistinct[]data//DeleteDuplicatesBy[KeySort]%% == %Related Guides
Text
Wolfram Research (2020), SPARQLDistinct, Wolfram Language function, https://reference.wolfram.com/language/GraphStore/ref/SPARQLDistinct.html.
CMS
Wolfram Language. 2020. "SPARQLDistinct." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/GraphStore/ref/SPARQLDistinct.html.
APA
Wolfram Language. (2020). SPARQLDistinct. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/GraphStore/ref/SPARQLDistinct.html
BibTeX
@misc{reference.wolfram_2026_sparqldistinct, author="Wolfram Research", title="{SPARQLDistinct}", year="2020", howpublished="\url{https://reference.wolfram.com/language/GraphStore/ref/SPARQLDistinct.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_sparqldistinct, organization={Wolfram Research}, title={SPARQLDistinct}, year={2020}, url={https://reference.wolfram.com/language/GraphStore/ref/SPARQLDistinct.html}, note=[Accessed: 15-June-2026]}