kasei / perlrdf

Deprecated in favor of the Attean package
26 stars 25 forks source link

RDF::Trine::Store::SPARQL->get_contexts() doesn't work with Virtuoso #140

Open minusdavid opened 7 years ago

minusdavid commented 7 years ago

I tried RDF::Trine::Store::SPARQL->get_contexts() with Virtuoso 06.01.3127 on Debian 7 Wheezy but it didn't return any results despite there being 4 graphs there.

The query in the module is: 'SELECT DISTINCT ?g WHERE { GRAPH ?g {} }'; It produces this error when I try it by hand: Virtuoso 37000 Error SP030: SPARQL compiler, line 3: syntax error at ''SELECT DISTINCT ?g WHERE { GRAPH ?g {} }'' before ';'

However, the following query works: "SELECT DISTINCT ?g { GRAPH ?g { ?s ?p ?o . } }"

I found the workable query via the following link: https://issues.apache.org/jira/browse/MARMOTTA-597

kasei commented 7 years ago

Hi @minusdavid. This is a known bug in Virtuoso that Openlink seems unwilling to fix. The workaround query you suggest would work, but can be VERY expensive to execute on various SPARQL implementations and so I've never been interested in changing get_contexts universally. That being said, if you (or someone else) would like to explore implementation approaches that would only perform that query conditionally (or automatically if it can be determined that the endpoint is running Virtuoso), I'd be happy to consider a PR.

minusdavid commented 7 years ago

Cheers @kasei, and thanks for the quick reply. I've only started playing around with Virtuoso and I'm noticing other bugs and non-conformance with the SPARQL specs, so I'm thinking of abandoning it as a triplestore in any case.

I noticed I couldn't add triples via the SPARQL store work either, since Virtuoso uses "query" instead of "update" and requires "query" to be in the query string rather than in the request message body. It seems utterly bizarre...

But reassuring that RDF::Trine is doing things the right way! Now I just need to find a triplestore that also works correctly.

minusdavid commented 7 years ago

Looks like maybe newer versions of Virtuoso don't have that SPARQL update problem (https://github.com/openlink/virtuoso-opensource/issues/215), but that's unfortunate about get_contexts..

minusdavid commented 7 years ago

That said, regarding the update problem, it looks like RDFLib made a workaround like you suggested (https://github.com/rancas/rdflib/commit/09a275bdd4ab9dbe40100b9b74d08d42a356cc73).