Skip to content

Instantly share code, notes, and snippets.

@namedgraph
Last active November 13, 2020 08:27
Show Gist options
  • Save namedgraph/be9f144086c0cf7b48171f82d6d0e0ac to your computer and use it in GitHub Desktop.
Save namedgraph/be9f144086c0cf7b48171f82d6d0e0ac to your computer and use it in GitHub Desktop.
Splits the default RDF graph into named graph per subject URI (does not change the default graph)
INSERT {
GRAPH ?graph {
?s ?p ?o .
}
}
WHERE
{ { SELECT DISTINCT ?s
WHERE
{ ?s ?p ?o }
}
BIND(SHA1(str(?s)) AS ?sha1)
BIND(uri(concat(str(<graphs/>), ?sha1, "/")) AS ?graph)
?s ?p ?o
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment