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

Filter on empty ResultTable seems to break in some situations #162

Closed
niklas88 opened this issue Dec 13, 2018 · 5 comments
Closed

Filter on empty ResultTable seems to break in some situations #162

niklas88 opened this issue Dec 13, 2018 · 5 comments
Assignees
Labels

Comments

@niklas88
Copy link
Member

Querying for all the mons (wd:Q429088 mountains on a celestial object) with elevation above 8000 m on Wikidata Full crashes. Searching for mountains (wd:Q8502) on the other hand works. I think this is the same bug @joka921 was also looking at and is related to FILTER on an empty result table under some special circumstances.

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 ?subj ?label ?coord ?elev WHERE
{ 
  ?subj wdt:P31 wd:Q429088 .
  ?subj p:P2044 ?elev_s .
  ?elev_s psn:P2044 ?elev_v .
  ?elev_v wikibase:quantityAmount ?elev .
  ?subj wdt:P625 ?coord .
  ?subj rdfs:label ?label .

  FILTER (?elev > 8000.0) .
  FILTER langMatches(lang(?label), "en") .  
}
ORDER BY DESC(?elev)
@niklas88
Copy link
Member Author

Another query which triggers it is

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX wikibase: <http://wikiba.se/ontology-beta#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?occupation ?gender (AVG(?height) AS ?average_height) (COUNT(?height) AS ?count) WHERE {
  ?x wdt:P31 wd:Q5 .
  ?x p:P2048 ?statement .
  ?x wdt:P21 ?gender_id .
  ?gender_id rdfs:label ?gender .
  FILTER langMatches(lang(?gender), "en") .
  ?statement psv:P2048 ?value .
  ?value wikibase:quantityNormalized ?quantity .
  ?quantity wikibase:quantityUnit wd:Q11573 .
  ?quantity wikibase:quantityAmount ?height .
  ?x wdt:P106 ?occupation_id .
  ?occupation_id rdfs:label ?occupation .
  FILTER langMatches(lang(?occupation), "en") .
  FILTER (?height < 3)
}
GROUP BY ?occupation ?gender
HAVING (?count > 100)
ORDER BY DESC(?average_height)

where fixing PREFIX wikibase: <http://wikiba.se/ontology-beta#> to PREFIX wikibase: <http://wikiba.se/ontology#> makes the query work again because the result is no longer empty.

@floriankramer
Copy link
Member

floriankramer commented Dec 14, 2018

When running the first query on the new wikidata-full backend the result without the filters in not empty, but with the filters it still crashes, so the bug must be related to something else.
The following query reproduces something that looks like the same bug on the scientists dataset:

SELECT ?a ?h WHERE {
 {
  SELECT ?a ?h ?h1 ?h2 ?h3 ?h4 ?h5 WHERE {
 ?a <Height> ?h .
 ?a <Height> ?h1 .
 ?a <Height> ?h2 .
 ?a <Height> ?h3 .
 ?a <Height> ?h4 .
 ?a <Height> ?h5 .
}
}
 ?a <Height> ?h6 .
 FILTER(?h > 1.6)
}

@floriankramer
Copy link
Member

Filter were never designed to run on ResultTables with more than 5 columns, as they are always applied as early as possible. Due to the introduction of query subgraphs and having clauses filers now need to be able to run on arbitrarily wide ResultTables.

@niklas88
Copy link
Member Author

@floriankramer interesting, can you point me to a code line where the 5 column assumption becomes apparent?

@floriankramer
Copy link
Member

Apparently fixing #... does not auto close issues. This was fixed in #163.

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

No branches or pull requests

2 participants