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

LOAD with WHERE block #202

Open
chiarcos opened this issue Feb 28, 2024 · 3 comments
Open

LOAD with WHERE block #202

chiarcos opened this issue Feb 28, 2024 · 3 comments
Labels
enhancement New feature or request update Extends the Update spec

Comments

@chiarcos
Copy link

chiarcos commented Feb 28, 2024

In order to call external web services from a SPARQL query, it would be helpful to be able to LOAD their results.

The example below shows how such a query could work. The WHERE block generates an access URL dynamically (based on the content in the current graph). The access URL contains a string (text=...) that is analysed by a web service (https://api.dbpedia-spotlight.org/en/annotate?...) and returns dynamically generated RDF data (try this url)

PREFIX nif: <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
LOAD ?access_uri
WHERE { 
  ?s  a nif:Sentence; rdfs:comment ?comments.
  BIND(replace(?comments,".*text\\s*=\\s*([^\n]*).*","$1") as ?text)
  BIND(URI(
      CONCAT(
         "https://api.dbpedia-spotlight.org/en/annotate?text=",
         ENCODE_FOR_URI(?text), 
         "&url=",str(?s))) as ?access_uri)
}

Notes:

  • I can see why this could be considered harmful, because people might easily overload their end points. But this could be controlled by making this an optional feature and/or allowing implementations do enable or to disable WHERE block support for LOAD.
  • This proposal focuses on updates, but a similar effect could also be achieved/required during querying, e.g., using the FROM keyword. But note that at the moment, variable values for FROM are not possible because it is out of scope for variable binding.

PS: I know this is not in the core interest of the RDF-Star proposal, but it could be something to be considered in the process of developing SPARQL 1.2.

@rubensworks
Copy link
Member

I suspect this won't be in-scope for the current WG.
But you could consider opening this as an issue here, for consideration for a future WG: https://github.com/w3c/sparql-dev

@afs
Copy link
Collaborator

afs commented Aug 26, 2024

Yes, as @rubensworks suggest, this is for sparql-dev. The area of "scripting for federated query" is quite a large area that could have its own community of interest. Its going to have to handle errors and partial errors carefully to given an understandable and controllable outcome.

See also https://jena.apache.org/documentation/query/service_enhancer.html (a contribution from @AKSW).

@afs
Copy link
Collaborator

afs commented Sep 19, 2024

Hi @chiarcos,

The working group looked at this issue. Given it is not core to RDF Star, the WG asked that it be moved to sparql-dev CG to get wider input and discussion. All content is transferred.

@afs afs transferred this issue from w3c/sparql-update Sep 19, 2024
@afs afs added enhancement New feature or request update Extends the Update spec labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request update Extends the Update spec
Projects
None yet
Development

No branches or pull requests

3 participants