rdf4j
rdf4j copied to clipboard
Allow query explanation via HTTPRepository / REST API
The query explain feature (see GH-2044) should be extended to allow use over HTTP. This will enable using it in the HTTPRepository as well as in any non-Java environment that communicates via the REST API.
@hmottestad @kenwenzel Hello, I am interested in this feature and would like to contribute. If RDF4J maintainers still want this rest API, I am happy to discuss api design with you
That would be very welcome from our side.
https://rdf4j.org/documentation/reference/rest-api/
Here is the API docs that we have. Did you already have an idea for how to extend it to support query explanation?
Add POST Request /repositories/{repository_id}/explain
Request Body:
{
"query": "SELECT * WHERE {?S ?O ?P}",
"level": "Timed"
}
Response:
{
"explain": ".........."
}
Core Logic:
try (final RepositoryConnection connection = RepositoryInterceptor.getRepositoryConnection()) {
final Explanation explanation = connection.prepareQuery(query).explain(level);
}
Optionally, we may integrate explain into the Workbench UI to enhance user interaction.
@hmottestad @kenwenzel would you prefer extending the sparql to do smth like
EXPLAIN [with limit] SPARQL
or try and do it through custom functions?
Neptune uses an additional HTTP Parameter: https://docs.aws.amazon.com/neptune/latest/userguide/sparql-explain-using.html
Maybe this is also something that we could do?
@kenwenzel Good idea.
If I understand correctly, we will use the existing SPARQL execution endpoints. If explain=mode is passed, it does query explanation, otherwise, execute this query.
@odysa Yes, this is how I understand it, too.
#5312 good for review