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

Federated queries with wdt:P18 (image) crash #1375

Open
tuukka opened this issue Jun 13, 2024 · 2 comments
Open

Federated queries with wdt:P18 (image) crash #1375

tuukka opened this issue Jun 13, 2024 · 2 comments

Comments

@tuukka
Copy link

tuukka commented Jun 13, 2024

I'm trying to get images related to OSM-Wikidata links, but my queries crash.

One error message (the query completes if I change the inner select to just SELECT ?item) :

Error processing query

Assertion `!isString()` failed. Please report this to the developers. In file "/local/data-ssd/qlever/qlever-code/src/parser/TripleComponent.h " at line 191
Your query was:

PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX osm: <https://www.openstreetmap.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX osmkey: <https://www.openstreetmap.org/wiki/Key:>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX osm2rdfkey: <https://osm2rdf.cs.uni-freiburg.de/rdf/key#>
SELECT ?item ?osm_id ?osmName ?image ?geometry WHERE {
  SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
    SELECT ?item ?image {
      ?item wdt:P31/wdt:P279* wd:Q473972 .
      ?item wdt:P18 ?image .
    }
  }
  ?osm_id osm2rdfkey:wikidata ?item .
  ?osm_id osmkey:boundary "protected_area" .
#  { ?osm_id rdf:type osm:way . } UNION { ?osm_id rdf:type osm:relation . }

  ?osm_id geo:hasGeometry/geo:asWKT ?geometry .
  ?osm_id osmkey:name ?osmName
}
ORDER BY ?item

Alternatively, if I mark the wdt:P18 as optional, I get another error message:

Error processing query

Parse error at byte position 8: A check for a required element failed The next 500 bytes are: .
Your query was:

PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX osm: <https://www.openstreetmap.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX osmkey: <https://www.openstreetmap.org/wiki/Key:>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX osm2rdfkey: <https://osm2rdf.cs.uni-freiburg.de/rdf/key#>
SELECT ?item ?osm_id ?osmName ?image ?geometry WHERE {
  SERVICE <https://qlever.cs.uni-freiburg.de/api/wikidata> {
    SELECT ?item ?image {
      ?item wdt:P31/wdt:P279* wd:Q473972 .
      OPTIONAL { ?item wdt:P18 ?image . }
    }
  }
  ?osm_id osm2rdfkey:wikidata ?item .
  ?osm_id osmkey:boundary "protected_area" .
#  { ?osm_id rdf:type osm:way . } UNION { ?osm_id rdf:type osm:relation . }

  ?osm_id geo:hasGeometry/geo:asWKT ?geometry .
  ?osm_id osmkey:name ?osmName
}
ORDER BY ?item
@joka921
Copy link
Member

joka921 commented Jun 13, 2024

Thanks for reporting this.
The underlying issue is the following:
QLever currently doesn't like if the result of a Service has contains a blank node (that is probably the cause of the !isString issue...
or if the Service returns undefined/optional values (your problem with optionals).
We currently have someone (@UNEXENU) working on the SERVICE implementation to get rid of such issues (among others).

A current workaround for your concrete query is to filter out the blank nodes (which you are probably not interested in anyway) by adding a
FILTER (!ISBLANK(?image))
inside the SERVICE clause:
[click me] (https://qlever.cs.uni-freiburg.de/osm-planet/iGdZki)

@tuukka
Copy link
Author

tuukka commented Jun 13, 2024

Thank you! The workaround is suitable for me. To allow OPTIONAL, I can even change the missing values to a placeholder value: https://qlever.cs.uni-freiburg.de/osm-planet/wbFBTJ

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