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

Demo query is incompatible with Wikidata Query Services and Apache Jena #604

Closed
WolfgangFahl opened this issue Feb 19, 2022 · 4 comments
Closed

Comments

@WolfgangFahl
Copy link

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?mountain ?mountain_label (MAX(?elevation) AS ?elevation) (SAMPLE(?coordinates) AS ?coordinates) WHERE {
  ?mountain wdt:P31 wd:Q8502 .
  ?mountain p:P2044/psn:P2044/wikibase:quantityAmount ?elevation .
  ?mountain wdt:P625 ?coordinates .
  ?mountain rdfs:label ?mountain_label .
  FILTER(?elevation >= 8000.0) .
  FILTER (LANG(?mountain_label) = "en")
}
GROUP BY ?mountain ?mountain_label
ORDER BY DESC(?elevation)

leads to a stackoverflow error in the WikidataQuery Service and and an error message in Apache Jena.

Parse error: Variable used when already in-scope: ?elevation in ((AGG ?.0 MAX(?elevation)) AS ?elevation)
@WolfgangFahl
Copy link
Author

# Mountains higher than 8000 m
# fixes:
# https://qlever.cs.uni-freiburg.de/wikidata/F7JXq3
# see https://github.com/ad-freiburg/qlever/issues/604
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?mountain ?mountain_label (MAX(?elevationValues) AS ?elevation) (SAMPLE(?coordinateValues) AS ?coordinates) WHERE {
  ?mountain wdt:P31 wd:Q8502 .
  ?mountain p:P2044/psn:P2044/wikibase:quantityAmount ?elevationValues .
  ?mountain wdt:P625 ?coordinateValues .
  ?mountain rdfs:label ?mountain_label .
  FILTER(?elevationValues >= 8000.0) .
  FILTER (LANG(?mountain_label) = "en")
}
GROUP BY ?mountain ?mountain_label
ORDER BY DESC(?elevation)

try it! works

@WolfgangFahl
Copy link
Author

using the sparqlquery command line from https://github.com/WolfgangFahl/pyLoDStorage

sparqlquery -qp sampledata/wikidata.yaml -qn MountainsHigher8000m -f github

Mountains higher than 8000 m

https://qlever.cs.uni-freiburg.de/wikidata/F7JXq3

query

# Mountains higher than 8000 m
# fixes:
# https://qlever.cs.uni-freiburg.de/wikidata/F7JXq3
# see https://github.com/ad-freiburg/qlever/issues/604
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX psn: <http://www.wikidata.org/prop/statement/value-normalized/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?mountain ?mountain_label (MAX(?elevationValues) AS ?elevation) (SAMPLE(?coordinateValues) AS ?coordinates) WHERE {
  ?mountain wdt:P31 wd:Q8502 .
  ?mountain p:P2044/psn:P2044/wikibase:quantityAmount ?elevationValues .
  ?mountain wdt:P625 ?coordinateValues .
  ?mountain rdfs:label ?mountain_label .
  FILTER(?elevationValues >= 8000.0) .
  FILTER (LANG(?mountain_label) = "en")
}
GROUP BY ?mountain ?mountain_label
ORDER BY DESC(?elevation)

result

mountain mountain_label elevation coordinates
Q513 Mount Everest 8850 Point(86.925277777 27.988055555)
Q43512 K2 8610 Point(76.513333333 35.881111111)
Q82019 Kanchenjunga 8586 Point(88.133333 27.7)
Q168702 Lhotse 8516 Point(86.933333333 27.961666666)
Q169986 Makalu 8485 Point(87.088611111 27.889166666)
Q11237699 Lhotse Shar 8383 Point(86.943333333 27.958333333)
Q170089 Cho Oyu 8188 Point(86.660833333 28.094166666)
Q165440 Dhaulagiri 8167 Point(83.495277777 28.696111111)
Q170070 Manaslu 8163 Point(84.559722222 28.55)
Q130736 Nanga Parbat 8126 Point(74.59 35.239166666)
Q16466024 Annapurna I 8091 Point(83.82 28.5958)
Q187138 Gasherbrum 8080 Point(76.696388888 35.724444444)
Q180996 Broad Peak 8051 Point(76.568055555 35.810555555)
Q186853 Gasherbrum II 8034 Point(76.652777777 35.7575)
Q105124 Shishapangma 8027 Point(85.779722222 28.352222222)

@hannahbast
Copy link
Member

Just tried the query again on QLever, it works fine. The WDQS gives a java.lang.StackOverflowError, but that is not our problem.

@WolfgangFahl
Copy link
Author

WolfgangFahl commented Jul 4, 2022

Indeed

sparqlquery -qp sampledata/wikidata.yaml -qn MountainsHigher8000m -f github -en qlever-wikidata-proxy

now works

result

mountain mountain_label elevation coordinates
http://www.wikidata.org/entity/Q513 Mount Everest 8850 Point(86.925277777 27.988055555)
http://www.wikidata.org/entity/Q43512 K2 8610 Point(76.513333333 35.881111111)
http://www.wikidata.org/entity/Q82019 Kanchenjunga 8586 Point(88.133333 27.7)
http://www.wikidata.org/entity/Q168702 Lhotse 8516 Point(86.933333333 27.961666666)
http://www.wikidata.org/entity/Q169986 Makalu 8485 Point(87.088611111 27.889166666)
http://www.wikidata.org/entity/Q11237699 Lhotse Shar 8383 Point(86.943333333 27.958333333)
http://www.wikidata.org/entity/Q170089 Cho Oyu 8188 Point(86.660833333 28.094166666)
http://www.wikidata.org/entity/Q165440 Dhaulagiri 8167 Point(83.495277777 28.696111111)
http://www.wikidata.org/entity/Q170070 Manaslu 8163 Point(84.559722222 28.55)
http://www.wikidata.org/entity/Q130736 Nanga Parbat 8126 Point(74.59 35.239166666)
http://www.wikidata.org/entity/Q16466024 Annapurna I 8091 Point(83.82 28.5958)
http://www.wikidata.org/entity/Q187138 Gasherbrum 8080 Point(76.696388888 35.724444444)
http://www.wikidata.org/entity/Q180996 Broad Peak 8051 Point(76.568055555 35.810555555)
http://www.wikidata.org/entity/Q186853 Gasherbrum II 8034 Point(76.652777777 35.7575)
http://www.wikidata.org/entity/Q105124 Shishapangma 8027 Point(85.779722222 28.352222222)

on my computer the wikidata query service endpoint responds just fine with the same result.

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