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

Add support for URI and CONCAT #501

Closed
dpriskorn opened this issue Oct 14, 2021 · 2 comments
Closed

Add support for URI and CONCAT #501

dpriskorn opened this issue Oct 14, 2021 · 2 comments

Comments

@dpriskorn
Copy link

PREFIX wdt: 
PREFIX wd: 
PREFIX wikibase: 
#defaultView:Map
#title:Map of all humans with Libris-URI according to birthplace in Wikidata
#note: Times out on BlazeGraph
SELECT ?item ?librisuri ?coord (sample(?img) AS ?image) (sample(?map) AS ?map) WHERE {
  #?item wdt:P625 ?coord.
  ?item wdt:P5587 ?librisid;
        wdt:P31 wd:Q5;
        wdt:P19 ?birthplace. 
  ?birthplace wdt:P625 ?coord.
  OPTIONAL {?item wdt:P18 ?img}.
  OPTIONAL {?item wdt:P242 ?map}.
  BIND(URI(CONCAT("https://libris.kb.se/katalogisering/",?librisid)) AS ?librisuri)
#SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
} 
group by ?item ?librisuri ?coord 

Exception: ParseException, cause: Unexpected input: URI(CONCAT("https://libris.kb.se/katalogisering/",?librisid)) AS ?librisuri) #SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". } } group by ?item ?librisuri ?coord 

This works:

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
#defaultView:Map
#title:Map of all humans with Libris-URI according to birthplace in Wikidata
#note: Times out on BlazeGraph
SELECT ?item #?librisuri 
?coord (sample(?img) AS ?image) (sample(?map) AS ?map) WHERE {
  #?item wdt:P625 ?coord.
  ?item wdt:P5587 ?librisid;
        wdt:P31 wd:Q5;
        wdt:P19 ?birthplace. 
  ?birthplace wdt:P625 ?coord.
  OPTIONAL {?item wdt:P18 ?img}.
  OPTIONAL {?item wdt:P242 ?map}.
  # BIND(URI(CONCAT("https://libris.kb.se/katalogisering/",?librisid)) AS ?librisuri)
#SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
} 
group by ?item 
#?librisuri 
?coord 
@hannahbast
Copy link
Member

hannahbast commented Oct 14, 2021

@dpriskorn Thanks, Dennis. It has nothing to do with the BIND. The issue here is that most functions (like URI or CONCAT) are not yet supported, but will be very soon. As you can see in the last commits, we are currently working on an efficient implementation for general SPARQL expressions. Once that groundwork is laid (the code is already all there, just not yet fully reviewed), it will be very easy to add arbitrary functions.

Without the URI and CONCAT, the query works fine and is also fast (300ms on QLever vs. 5s on Blazegraph vs. 1.6s on Virtuoso, if not cached = wait some time before you ask the query again).

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
SELECT ?item ?librisuri ?coord (SAMPLE(?img) AS ?image) (SAMPLE(?map) AS ?map) WHERE {
  ?item wdt:P5587 ?librisid ;
        wdt:P31 wd:Q5 ;
        wdt:P19 ?birthplace . 
  ?birthplace wdt:P625 ?coord .
  OPTIONAL { ?item wdt:P18 ?img } .
  OPTIONAL { ?item wdt:P242 ?map } .
  BIND(?librisid AS ?librisuri)
} 
GROUP BY ?item ?librisuri ?coord

@dpriskorn dpriskorn changed the title Query with BIND fails with ParseException Add support for URI and CONCAT Jan 30, 2022
@hannahbast
Copy link
Member

Moved to #615

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants