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 with numerical constant does not work #114

Closed
hannahbast opened this issue Aug 28, 2018 · 4 comments
Closed

FILTER with numerical constant does not work #114

hannahbast opened this issue Aug 28, 2018 · 4 comments
Projects

Comments

@hannahbast
Copy link
Member

For example, on Wikipedia+FreebaseEasy, the following query does not work as expected (the result is empty, and with > instead of < nothing is filtered):

SELECT ?city ?country ?population WHERE {
  ?city <is-a> <City/Town/Village> .
  ?country <is-a> <Country> .
  ?city <Contained_by> ?country .
  ?city <Population> ?population .
  FILTER (?population < 1000000)
}
ORDER BY DESC(?population)
@joka921
Copy link
Member

joka921 commented Aug 29, 2018

I think I know the source of the problem: Value literals are stored in a special form in QLever (":value00000..."). Your bug looks like the translation of the filter value "1000000" into this form is not performed and thus this value is transformed into an Id which is smaller than that of All numeric literals (because '1' < ':' in ASCII). Since this is not the part of the QLever source I am familiar with, I would recommend @niklas88 or @floriankramer to check where this could be implemented best. (As far as I've seen the SparqlParser directly constructs the list of Filters, so probably it should be somewhere there).

@niklas88
Copy link
Member

niklas88 commented Aug 29, 2018

Ok so it turns out this does work:

SELECT ?city ?country ?population WHERE {
  ?city <is-a> <City/Town/Village> .
  ?country <is-a> <Country> .
  ?city <Contained_by> ?country .
  ?city <Population> ?population .
  FILTER (?population < "10000"^^xsd:integer)
}
ORDER BY DESC(?population)

Because currently QLever intentionally‽ only checks if the right hand side of the comparison is an XSD literal. Interestingly it looks like the FILTER comparisons also aren't symmetric, i.e. constants only work on the right side.

@hannahbast
Copy link
Member Author

hannahbast commented Aug 29, 2018 via email

@niklas88
Copy link
Member

@hannahbast yes it does. Also I'm currently working on supporting normal numeric constants as they are definitely in the SPARQL spec (see the PR linked here). Interestingly this actually kind of is a problem with the SPARQL parser as in a proper parser that would've already converted literals to their correct type. So my fix is kind of a workaround until we get the parser fixed.

@niklas88 niklas88 added this to In progress in QLever Aug 31, 2018
QLever automation moved this from In progress to Done Sep 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
QLever
  
Done
Development

No branches or pull requests

3 participants