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

QLever missing features or unexpected behavior #615

Open
hannahbast opened this issue Feb 26, 2022 · 65 comments
Open

QLever missing features or unexpected behavior #615

hannahbast opened this issue Feb 26, 2022 · 65 comments

Comments

@hannahbast
Copy link
Member

Whenever you encounter a query that you think should work (according to the SPARQL 1.1 standard) but throws an error message or gives an unexpected result, please post it here. Please check whether a similar query has already been posted before.

I will now move various queries from other issues here, so that we don't have one issue per query (which doesn't really help).

@hannahbast
Copy link
Member Author

The SERVICE keyword is not yet supported [reported by @WolfgangFahl on 26.02.2022]:

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

@hannahbast
Copy link
Member Author

Square brackets are not yet supported [reported by @dpriskorn on 25.02.2022]:

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

@hannahbast
Copy link
Member Author

Minor syntax features not yet supported [reported by @WolfgangFahl on 19.02.2022]:

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

Variant of the query that works: https://qlever.cs.uni-freiburg.de/wikidata/VgHqGB

@hannahbast
Copy link
Member Author

Currently, only GET queries are supported, not POST [reported by @WolfgangFahl on 19.02.2022]:

This is easy to fix and on our list.

This was referenced Feb 26, 2022
@hannahbast
Copy link
Member Author

String functions are not yet supported in QLever [reported by @dpriskorn on 28.01.2022]:

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

NOTE: The code for supporting functions in SPARQL expressions is all there. It's just a matter of adding more functions.

@hannahbast
Copy link
Member Author

String functions not yet implemented [reported by @WolfgangFahl on 28.01.2022]:

https://qlever.cs.uni-freiburg.de/wikidata/0fidpY

The following equivalent query works: https://qlever.cs.uni-freiburg.de/wikidata/m49coC

@hannahbast
Copy link
Member Author

Basic ?s ?p ?o query does not work yet in QLever [reported by @balhoff on 10.12.2021]:

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

NOTE: This is easy to implement and is on our list

This was referenced Feb 26, 2022
@jeremiahpslewis
Copy link

Quick question here, it's hard as a user to see which features are not currently supported if they are all in a single issue. What about using a query label to group all of these issues, but having separate issues for each failed query 'feature'?

@hannahbast
Copy link
Member Author

String functions URI and CONCAT not yet supported [reported by @dpriskorn on 15.10.2022]:

https://qlever.cs.uni-freiburg.de/wikidata/5sDHUw

This variant of the query works: https://qlever.cs.uni-freiburg.de/wikidata/aIbGvo

@WolfgangFahl
Copy link

@hannahbast
#607 shows how the sample queries can be tested with different endpoints.

@hannahbast
Copy link
Member Author

FILTER with arbitrary expressions not yet supported [reported by @graue70 on 03.09.2021]:

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

NOTE: The code for supporting arbitrary expressions is in place in the meantime, we "only" need to add this feature

@hannahbast
Copy link
Member Author

hannahbast commented Feb 26, 2022

Quick question here, it's hard as a user to see which features are not currently supported if they are all in a single issue. What about using a query label to group all of these issues, but having separate issues for each failed query 'feature'?

@jeremiahpslewis You are completely right and this issue is not for having a good overview, it's just to give people a chance to add a new query if they encounter one without opening a new issue every time. Having dozens of issues for things which are already on our list is not really helpful.

The solution I propose is that I add a page on the Wiki with a list of the features currently not supported (together with an estimate of when they will be supported and how hard it is).

@dpriskorn
Copy link

dpriskorn commented Feb 26, 2022

Do you accept pull requests? What would be a good first issue? 😀

@WolfgangFahl
Copy link

WolfgangFahl commented Feb 26, 2022

I have added more details to #607 and suggest to use named queries for continuous integration. IMHO it would be good to add the name of the query as comment e.g.

sparqlquery -qp wikidata.yaml --showQuery -qn HumansWithLibrisEntryAndImageAndMap 

named query HumansWithLibrisEntryAndImageAndMap

# humans with images and maps in swedish national library
# 53142 results in 20.6 seconds on Wikidata Query Service
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 {
  # humans with a Libris-URI (swedish national library) and a known birthplace
  ?item wdt:P5587 ?librisid;
        wdt:P31 wd:Q5;
        wdt:P19 ?birthplace.
  # birthplace coordinates
  ?birthplace wdt:P625 ?coord.
  # image of the subject
  OPTIONAL {?item wdt:P18 ?img}.
  # map of the subject
  OPTIONAL {?item wdt:P242 ?map}.
  BIND(URI(CONCAT("https://libris.kb.se/katalogisering/",?librisid)) AS ?librisuri)
}
group by ?item ?librisuri ?coord

@WolfgangFahl
Copy link

@hannahbast Having dozens of issues for things which are already on our list is not really helpful.
There is a tradeoff here. Personally i'd prefer an issue per case because referencing is much easier. Adding labels to the issues would probably help and then there is of course the "duplicate of ..." which makes sure there will be a core issue for each case.

@joka921
Copy link
Member

joka921 commented Feb 28, 2022

Do you accept pull requests? What would be a good first issue? grinning
Of course, see my email from yesterday.

@hannahbast
Copy link
Member Author

@anlam If you want the whole dataset, isn't the right thing to download it from Wikidata: https://dumps.wikimedia.org/wikidatawiki/entities/ ?

In principle, you can of course download the whole dataset with CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }, and it works, but I don't think that's a proper use of a SPARQL endpoint

@tuukka
Copy link

tuukka commented May 29, 2022

SELECT (?queryVariable AS ?resultVariable) does not give an error but produces an empty variable.

@hannahbast
Copy link
Member Author

@tuukka Can you provide a complete query?

@tuukka
Copy link

tuukka commented May 29, 2022

SELECT (?queryVariable AS ?resultVariable) does not give an error but produces an empty variable.

Example (should produce 192 nation states, produces 192 empty rows): https://qlever.cs.uni-freiburg.de/wikidata/qphky4

Of course, it's easy to work around by search-and-replace of ?queryVariable with ?resultVariable, but it's a reason why some queries from WDQS don't work directly in QLever.

@hannahbast
Copy link
Member Author

hannahbast commented May 29, 2022

Thanks, that looks like one of the many small deviations from the SPARQL 1.1 standard, which we are currently fixing.

@Qup42 @joka921 What do you think?

As a quick workaround, BIND is your friend and this equivalent query gives you the desired result: https://qlever.cs.uni-freiburg.de/wikidata/HOuTUH

@WolfgangFahl
Copy link

Here is an example of a "truly tabular" generated query with GROUP_CONCAT that does not seem to work:

# truly tabular aggregate query for 
# Q2020153:academic conference
# generated by trulytabular.py version 0.2.14 on 2022-07-28T08:27:46.370180
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?academic_conference ?academic_conferenceLabel
  (SAMPLE (?country) AS ?country_sample)
  (COUNT (?short_name) AS ?short_name_count)
  (GROUP_CONCAT (?short_name;SEPARATOR="⇹") AS ?short_name_list)
  (COUNT (?title) AS ?title_count)
  (GROUP_CONCAT (?title;SEPARATOR="⇹") AS ?title_list)
WHERE {
  # instanceof Q2020153:academic conference
  ?academic_conference wdt:P31 wd:Q2020153.
  # label
  ?academic_conference rdfs:label ?academic_conferenceLabel.  
  FILTER (LANG(?academic_conferenceLabel) = "en").
  # country (P17)
  OPTIONAL { 
    ?academic_conference wdt:P17 ?country. 
  }
  # short name (P1813)
  OPTIONAL { 
    ?academic_conference wdt:P1813 ?short_name. 
  }
  # title (P1476)
  OPTIONAL { 
    ?academic_conference wdt:P1476 ?title. 
  }
}
GROUP BY ?academic_conference ?academic_conferenceLabel
HAVING (COUNT(?country)=1)

@WolfgangFahl
Copy link

@joka921
Copy link
Member

joka921 commented Jul 28, 2022

@WolfgangFahl
Here is a variant of you query that works

There are two issues here: QLever's parser currently does not allow as a separator. I'll have to check, whether this has to be somehow escaped, or whether this is a bug in our parser implementation. I have therefore replaced the separator by .
The second issue is that HAVING(COUNT(... is currently not supported (QLever's Filter implementation is rather incomplete and does only allow a small set of expressions, but I am actively working on that. The workaround here is to explicitly bind the COUNT to a Variable in the SELECT clause and then filter this variable for equality with 1. This currently has the disadvantage that this "internal" variable is then selected in the result, but we are aware of this issue.

@WolfgangFahl
Copy link

Is there a way to emulate EXISTS and BOUND which both seem to be unimplemented?

EDIT: I found !ASK but cannot use it in a FILTER: Exception: ParseException, cause: ! is not a valid left hand side for a filter. EDIT2: boolean literals don't seem to be implemented as false = ASK ... results in Unexpected input: false = ASK ... EDIT3: COALESCE also unimplemented.

see https://qlever.cs.uni-freiburg.de/wikidata/zitfWe for coalesce not working

@aindlq
Copy link

aindlq commented Dec 5, 2023

Not supported: ASK queries are currently not supported by QLever.

On can use LIMIT 1 query as a workaround:
SELECT * WHERE {...} LIMIT 1

@LorenzBuehmann
Copy link

Is there an overview about the current coverage of SPARQL 1.1 features resp. functions. Or maybe just a list of the missing features/functions?
That would be more convenient than checking QLever demo or own setups by executing queries I think.

From what I can can tell since I tried it in the morning, hash functions are missing. But I'm looking for a list according the SPARQL 1.1 specs, e.g.

7.4.1 Functional Forms

  • 7.4.1.1 bound
  • 7.4.1.2 IF
  • 7.4.1.3 COALESCE
  • 7.4.1.4 NOT EXISTS and EXISTS
  • 7.4.1.5 logical-or
  • 7.4.1.6 logical-and
  • 7.4.1.7 RDFterm-equal
  • 7.4.1.8 sameTerm
  • 7.4.1.9 IN
  • 7.4.1.10 NOT IN

7.4.2 Functions on RDF Terms

  • 7.4.2.1 isIRI
  • 7.4.2.2 isBlank
  • 7.4.2.3 isLiteral
  • 7.4.2.4 isNumeric
  • 7.4.2.5 str
  • 7.4.2.6 lang
  • 7.4.2.7 datatype
  • 7.4.2.8 IRI
  • 7.4.2.9 BNODE
  • 7.4.2.10 STRDT
  • 7.4.2.11 STRLANG
  • 7.4.2.12 UUID
  • 7.4.2.13 STRUUID

Functions on Strings

  • 7.4.3.1 Strings in SPARQL Functions
  • 7.4.3.1.1 String arguments
  • 7.4.3.1.2 Argument Compatibility Rules
  • 7.4.3.1.3 String Literal Return Type
  • 7.4.3.2 STRLEN
  • 7.4.3.3 SUBSTR
  • 7.4.3.4 UCASE
  • 7.4.3.5 LCASE
  • 7.4.3.6 STRSTARTS
  • 7.4.3.7 STRENDS
  • 7.4.3.8 CONTAINS
  • 7.4.3.9 STRBEFORE
  • 7.4.3.10 STRAFTER
  • 7.4.3.11 ENCODE_FOR_URI
  • 7.4.3.12 CONCAT
  • 7.4.3.13 langMatches
  • 7.4.3.14 REGEX
  • 7.4.3.15 REPLACE

7.4.4 Functions on Numerics

  • 7.4.4.1 abs
  • 7.4.4.2 round
  • 7.4.4.3 ceil
  • 7.4.4.4 floor
  • 7.4.4.5 RAND

7.4.5 Functions on Dates and Times

  • 7.4.5.1 now
  • 7.4.5.2 year
  • 7.4.5.3 month
  • 7.4.5.4 day
  • 7.4.5.5 hours
  • 7.4.5.6 minutes
  • 7.4.5.7 seconds
  • 7.4.5.8 timezone
  • 7.4.5.9 tz

7.4.6 Hash Functions

  • 7.4.6.1 MD5
  • 7.4.6.2 SHA1
  • 7.4.6.3 SHA256
  • 7.4.6.4 SHA384
  • 7.4.6.5 SHA512

@WolfgangFahl
Copy link

see #1247 and #859 and WDscholia/scholia#2412 how a systematic testing approach could look like. Is there somewhere a list of example queries according to the SPARQL spec that we could pick up?

@LorenzBuehmann
Copy link

There is the SPARQL 1.1 test suite: https://www.w3.org/2009/sparql/docs/tests/summary.html
The test structure is described here: https://www.w3.org/2009/sparql/docs/tests/README.html

It provides data, query and expected results w.r.t. the standard.

@LorenzBuehmann
Copy link

I saw a query in the QLever "OHM Planet" demo:

SELECT ?p ?count ?percent WHERE {
  { SELECT ?p (COUNT(?p) AS ?count) WHERE { ?s ?p ?o } GROUP BY ?p }
  BIND(100 * ?count / SUM(?count) AS ?percent)
}
ORDER BY DESC(?count)

I'm pretty sure this is non-standard SPARQL as aggregate functions are not allowed in a BIND expression. Is this intended and supposed to be a feature of QLever then?

With standard SPARQL it would be a more verbose query like

SELECT ?p ?count_p ?percent WHERE {
  { SELECT (COUNT(?s) AS ?count_total) WHERE {?s ?p ?o}}
  { SELECT ?p (COUNT(?p) AS ?count_p) WHERE { ?s ?p ?o } GROUP BY ?p }
  BIND(100 * ?count_p / ?count_total AS ?percent)
}
ORDER BY DESC(?count_p)

@tokarenko
Copy link

Please advise if the following SPARQL expression is on the development roadmap?

... WHERE BIND (EXISTS {SELECT ...

If it is not, I would be grateful if you could support it. Having this expression in SPARQL query raises the following error: Invalid SPARQL query: Built-in function "exists { select where{ http://test.domain/device.owl#interface/address ?p ?o.} limit1 }" not yet implemented; if you need it, just add it to SparqlQleverVisitor.cpp::visitTypesafe(Parser::BuiltInCallContext following the already implemented functions there

@Qup42
Copy link
Member

Qup42 commented Apr 24, 2024

Could you post the full query @tokarenko?

  • The name of the built-in function is very strange. Something is not right there.
  • It seems that you have a raw URL in query. You have to wrap it angle brackets: <http://test.domain/device.owl#interface/address>.

@LorenzBuehmann
Copy link

LorenzBuehmann commented Apr 24, 2024

in the error message it looks like the subquery has no projection, is this correct? Please show the whole query.

Other than that, I think (not) exists function is simply not implemented yet. It won't work even with a a correct subquery.

@tokarenko
Copy link

I am trying to use qLever with my custom ontology behind a SPARQL federation engine.

I am trying to get "1.1.1.1" from the following triple:
<http://test.domain/device.owl#core1_Gi0/1_ipv4_address> <http://test.domain/device.owl#IP> "1.1.1.1"^^<http://www.w3.org/2001/XMLSchema#string> .

The query is as follows:

prefix onto: <http://test.domain/device.owl#>
SELECT ?ip WHERE {
  <http://test.domain/device.owl#core1_Gi0/1_ipv4_address> onto:IP ?ip
}

Federation engine queries qLever as follows:

prefix onto: <http://test.domain/device.owl#>
select * 
where {
  bind (exists {select * 
    where {
      ?s onto:IP ?o .
    }
    limit 1 } as ?b0)
  bind (exists {select * 
    where {
      <http://test.domain/device.owl#core1_Gi0/1_ipv4_address> onto:IP ?ip .
    }
    limit 1 } as ?b1)
}
limit 1000 

I tried Ontotext GraphDB with the same ontology. It works as expected. So, I assume the query is fine.

@Qup42
Copy link
Member

Qup42 commented May 3, 2024

I had a look into the code. exists and not exists are not implemented. The error message is wrong. It should of course mark that EXISTS is not implemented instead of marking the whole sub pattern.

@BMI24
Copy link

BMI24 commented Jun 18, 2024

While the simple s-p-o query works, restricting it to ?s a ?o fails: https://qlever.cs.uni-freiburg.de/wikidata/TqjfBa

@BMI24
Copy link

BMI24 commented Jun 18, 2024

Also, while the wiki claims that IN and NOT IN are supported, the relevant PR #1344 is not yet merged. The linked example query demonstrates a workaround (using VALUES), but not IN/NOT IN

@joka921
Copy link
Member

joka921 commented Jun 18, 2024

Hi,
Yes, #1344 is almost finished, and will implement IN/NOT IN
Also #1374 Will fix your other issue (LIMITS on single triples). The more general feature (limiting arbitrary results that run out of memory when run unlimited) is a work in process, but will probably still take some time..

@WolfgangFahl
Copy link

Please note that the https://github.com/WolfgangFahl/snapquery can now happily host the test queries as named parameterized queries. I intend to e.g. give all queries of this tickets names as i already did successfully for the tickets from the wikidata query service short names queries with the help of an LLM to guess the names, description and the like. @joka921 - i also sent you and e-mail recently - it might have ended up in your SPAM filter so it would be great if you get actively in touch. Do you have an official suite of test queries by now or shall we offer one as part of the snapquery project?

@agustaf9
Copy link

The DESCRIBE keyword is not supported. I have not seen it mentioned anywhere in the issues or in the wiki.

@hannahbast
Copy link
Member Author

@agustaf9 Thanks for pointing that out, I have added DESCRIBE and ASK to the list on https://github.com/ad-freiburg/qlever/wiki/Current-deviations-from-the-SPARQL-1.1-standard, together with simple workarounds.

@WolfgangFahl I missed your last request and reading it now, I am not sure I understand it. Could you provide a bit more context?

@Rdataflow
Copy link

Just a detail: If I understand correctly NOW() has been implemented by #1377

SELECT (NOW() AS ?now) WHERE {}

@athalhammer
Copy link

athalhammer commented Sep 18, 2024

My favorite Wikidata query is not working. Main reason is that qlever assumes that the regex we are trying to match is a static string but, as I understand the spec, it can also be derived from a bound variable. This is probably hard to optimize as the search space opens to potentially >10k or hundreds of thousands of regular expressions with which we want to filter potentially 1bn records.

#Cell lines with names that could also be URLs (Internet of Cell Lines).

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT * WHERE {
  {
    SELECT ?cell_line ?cell_line_name WHERE {
      ?cell_line wdt:P31 wd:Q21014462;
                 rdfs:label ?cell_line_name.
          FILTER(LANG(?cell_line_name) = "en").
          Filter REGEX(STR(?cell_line_name), "^[\\w\\-\\.]+\\.[A-z]+$")
    }
  }
  ?tld wdt:P31/wdt:P279* wd:Q14296;
       rdfs:label ?tld_name.
  FILTER(LANG(?tld_name) = "en").
  FILTER REGEX(STR(?cell_line_name), CONCAT(REPLACE(STR(?tld_name), "\\.", "\\\\."), "$"), "i")
  BIND(URI(CONCAT("http://", ?cell_line_name)) as ?url)
}

@hannahbast
Copy link
Member Author

@athalhammer Thanks for the query. Yes, variable REGEX expressions are not yet supported. Not because it's hard but because we didn't get to do it yet.

However, for your particular query you can simple use STRENDS: https://qlever.cs.uni-freiburg.de/wikidata/3oYHYU

#Cell lines with names that could also be URLs (Internet of Cell Lines).
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT * WHERE {
  {
    SELECT ?cell_line ?cell_line_name WHERE {
      ?cell_line wdt:P31 wd:Q21014462 ;
                 rdfs:label ?cell_line_name .
      FILTER (LANG(?cell_line_name) = "en") .
      FILTER REGEX(?cell_line_name, "^[\\w\\-\\.]+\\.[A-z]+$")
    }
  }
  ?tld wdt:P31/wdt:P279* wd:Q14296 ;
       rdfs:label ?tld_name .
  FILTER (LANG(?tld_name) = "en") .
  FILTER STRENDS(LCASE(?cell_line_name), LCASE(?tld_name))
  BIND (URI(CONCAT("http://", ?cell_line_name)) AS ?url)
}

@athalhammer
Copy link

Thanks @hannahbast ! Just wanted to verify my perception that this should be supported (at some point) and let you know just in case you were not aware of it.

You are right about STRENDS - it is a lot simpler.

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