qlever icon indicating copy to clipboard operation
qlever copied to clipboard

Behavior on missing prefixes should be consistent and user-friendly

Open WolfgangFahl opened this issue 2 years ago • 3 comments

after #631 was fixed i tried activating the test again but the test fails for named query cities. I assume the prefixes are missing in this case and would suggest to change the error message accordingly e.g. adding "are some prefix declarations missing ..."

sparql:

SELECT DISTINCT ?name ?population WHERE {
  ?city wdt:P31/wdt:P279* wd:Q515 .
  ?city wdt:P17 wd:Q183 .
  ?city wdt:P1082 ?population .
  ?city rdfs:label ?name .
  FILTER (LANG(?name) = "en")
}
ORDER BY DESC(?population)

{ "exception": "BAD QUERY (No vocabulary entry for wd:Q515; in ../src/engine/QueryPlanner.cpp, line 374, function QueryPlanner::optimize(ParsedQuery::GraphPattern*)::<lambda(auto:132&&)> [with auto:132 = GraphPatternOperation::TransPath&])", "query": "SELECT DISTINCT ?name ?population WHERE {\n ?city wdt:P31/wdt:P279* wd:Q515 .\n ?city wdt:P17 wd:Q183 .\n ?city wdt:P1082 ?population .\n ?city rdfs:label ?name .\n FILTER (LANG(?name) = "en")\n}\nORDER BY DESC(?population)\n", "resultsize": 0, "status": "ERROR", "time": { "computeResult": 0, "total": 0 } }

WolfgangFahl avatar Jul 04 '22 07:07 WolfgangFahl

https://qlever.cs.uni-freiburg.de/wikidata/BAN1wX works

WolfgangFahl avatar Jul 04 '22 07:07 WolfgangFahl

so the test still can't be commented out/activated:

def testQueryEndpoints(self):
        """
        tests the sparql endpoint commandline endpoint selection
        """
        testArgs=[
            {"en":"wikidata",},
            #{"en":"qlever-wikidata",},
            # workaround https://github.com/ad-freiburg/qlever/issues/631
            # {"en":"qlever-wikidata-proxy",},
        ]

WolfgangFahl avatar Jul 04 '22 07:07 WolfgangFahl

@WolfgangFahl I don't understand what you mean by "the test can't comment out". I would suggest that you add the PREFIX definitions (which are mandatory) in your test queries!

@hannahbast @Qup42 The issue (concerning usability, not functionality) at hand is that QLever shows different behavior on missing prefixes. In many times it will just not find the IRIs and thus yield an empty result, while in others (e.g. property paths with fixed objects, see the example above) it fails with a not-optimal error message. The behavior should at least be consistent. I suggest always throwing an exception when a prefix is used but not defined. This can be implemented directly in the new SPARQL parser by @Qup42 which should perform the expansion of the prefixes. Let me know what you think should be the desired behavior there.

joka921 avatar Jul 04 '22 08:07 joka921

Your example query now returns a useful error. We're also very near to having the whole query parser ported to ANTLR. Once this is finished the error messages should be consistent for all parts of the query excepet for one (Filters). Then plan is to then also return the exact position of the clause that caused the error. The clause could then e.g. be highlighted directly in the Query itself. This could look something like this: image

Qup42 avatar Aug 27 '22 22:08 Qup42

Ok , so in the meantime we consistently use the new parser, which directly complains on missing prefixes with a useful message. So I think I can close this issue now.

joka921 avatar Sep 23 '22 09:09 joka921