Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON+LD/RDF serialization of SPARQL queries #4

Open
JervenBolleman opened this issue Apr 2, 2019 · 6 comments
Open

JSON+LD/RDF serialization of SPARQL queries #4

JervenBolleman opened this issue Apr 2, 2019 · 6 comments
Labels
protocol improving sending queries over the wire query Extends the Query spec results application/sparql-results+rainbows

Comments

@JervenBolleman
Copy link
Collaborator

Upto now SPARQL has been defined as a string of characters. However, there is a wish for an easier to manipulate format of queries.

Why?

It is currently difficult to give back feedback to users regarding how their query was executed and can be improved. Systems that do this need to patch query strings, which even for simple cases like automatically adding OFFSET and LIMIT clauses in the right place of a query string is not straight forward.

This feature would be basic building block for sharing query execution plans as an RDF/JSON+LD query object can be extended to as in the strawman example below that there is an error and the kind of join type planned by the DB.

SELECT ?somethingBad ?badClass WHERE { ?somethingBad a ?badClass , "bad" }
{"base": "<http://example/base/>",
 "project" : 
    {"variables" : [ "?somethingBad", "?badClass" ],
    "source" : 
        { "bgp" : [
            { "@type" : "triple" , 
            "subject" : "?somethingBad" ,
            "predicate" :  "rdf:type",
            "object" :  "?badClass" },
            { "@type" : "triple" , 
            "subject" : "?somethingBad" ,
            "predicate" :  "rdf:type",
            "object" :  "bad" ,
            "_error_" : "Error: can't have a literal for a type in our well designed system" },
        "_join_" : "join:hash"
        }
    }
}

The basics can be build from the SPARQL algebra model.

The desire for a JSON+LD model is so that it can be embedded in a application/sparql-results+json(+ld) result set.

Previous work

The SPIN notation has an notation for SPARQL in RDF.

Considerations for backward compatibility

SPARQL 1.0 and 1.1 only understand a query string, and do not expect JSON or RDF in a query field.
Suggestion is to add a new standard form parameter e.g. rdfquery for the http protocol.

Extending the formats of application/sparql-results with new fields can break many clients in the field.

@dydra
Copy link

dydra commented Apr 2, 2019

why would one not handle this through simple content negotiation?
see, for example, the "inspect" menu here.
that menu specifies an alternative accept media type for the sparql request.
when one is working on their own repository, the menu contains numerous entries.

as demonstrated there, each - including the execution reports, entails its own request.
if the requirement is to comprise several in a single request/response, then one could use multipart responses.

@tfrancart
Copy link

Related work : SPARQL.js as a JSON (not LD) representation of SPARQL queries : https://github.com/RubenVerborgh/SPARQL.js

@VladimirAlexiev
Copy link
Contributor

Related work: SSE (sparql query algebra), eg

@rubensworks
Copy link
Member

Related work : SPARQL.js as a JSON (not LD) representation of SPARQL queries : https://github.com/RubenVerborgh/SPARQL.js

Some more related work:

  • @joachimvh's SPARQLAlgebra.js builds upon SPARQL.js to adhere (as much as possible) to the SPARQL algebra.
  • GraphQL-LD is a way to convert GraphQL queries into SPARQL, which offers an alternative, but more restrictive SPARQL serialization.

@jindrichmynarz
Copy link

Would it be acceptable to require clients to compile the structured syntax of SPARQL queries to plain text? That way this change could be introduced gradually, starting without changes in the SPARQL 1.1 Protocol.

A few years ago I wrote a post exploring several ways how to generate SPARQL. Now I'm leaning on using a data DSL, using a common data format, such as JSON, which maps to native data structures in mainstream programming languages. SPIN RDF or other RDF syntaxes are a bit cumbersome, because the syntax of SPARQL requires explicit ordering that is clumsy to represent and manipulate in RDF.

@joernhees
Copy link

I agree that exchanging a query in a structured format rather than just a string would be beneficial in many cases (e.g., to put the parsed (maybe implicitly changed) query into the query result, maybe also as a basis for execution plans, etc. for debugging and other purposes).

I however don't think that this should be limited to or favor RDF/JSON-LD.

@JervenBolleman JervenBolleman added protocol improving sending queries over the wire query Extends the Query spec results application/sparql-results+rainbows labels Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
protocol improving sending queries over the wire query Extends the Query spec results application/sparql-results+rainbows
Projects
None yet
Development

No branches or pull requests

7 participants