On 5/8/17 1:13 PM, S.M.Shamimul Hasan wrote: > Dear Kingsley Idehen, > > Thank you very much for your reply. I have tried the solution with > sub-query that you provided me. However, it is giving me following > error. Could you please let me know how to fix it? > > Virtuoso 37000 Error SP031: SPARQL compiler: Variable 't' is used in > the query result set but not assigned > > Thanks a lot. > > Sincerely, > S.M.Shamimul Hasan > > > On Sun, May 7, 2017 at 12:59 PM, Kingsley Idehen > <kide...@openlinksw.com <mailto:kide...@openlinksw.com>> wrote: > > On 5/5/17 5:29 PM, S.M.Shamimul Hasan wrote: > > Hello, > > > > I am trying to run the following query on the Virtuoso SPARQL > endpoint > > to calculate the path between nodes. However, it is giving me > > following error. Could you please let me know how to fix it? BTW the > > query works fine for the Jena TDB. However, I want to use Virtuoso > > triplestore because it contains all of my datasets. > > > > Query: > > --------- > > PREFIX fused:<http://test.edu/vocab/> > > > > select ?super ?sub (count(?mid) as ?distance) from > > <http://test.edu/example/replicate9/ > <http://test.edu/example/replicate9/>> { > > ?mid fused:getInfectedBy* ?super. > > ?sub fused:getInfectedBy+ ?mid. > > } > > group by ?super ?sub > > order by ?super ?sub > > > > Error: > > -------- > > Virtuoso 37000 Error TR...: Query contains a transitive derived > table > > but neither end of it is bound by equality to other columns or > parameters. > > > > Thanks a lot. > > > > Sincerely, > > S.M.Shamimul Hasan > > ## Fails (correctly so) with Transitivity error; Virtuoso 37000 Error > TR...: Query contains a transitive derived table but neither end of it > is bound > > PREFIX fused:<http://test.edu/vocab/> > > SELECT ?super ?sub (count(?mid) as ?distance) > WHERE { > ?mid fused:getInfectedBy* ?super. > ?sub fused:getInfectedBy+ ?mid. > } > GROUP BY ?super ?sub > ORDER BY ?super ?sub > LIMIT 1 > > > ## Workaround using a sub-query > > PREFIX fused: <http://test.edu/vocab/> > > SELECT SAMPLE(?t) ?super ?sub (count(?mid) as ?distance) > WHERE { > { SELECT distinct ?super > WHERE { ?x fused:getInfectedBy ?super } > } > > ?mid fused:getInfectedBy* ?super. > ?sub fused:getInfectedBy+ ?mid. > } > GROUP BY ?super ?sub > ORDER BY ?super ?sub > LIMIT 1 >
See: http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=PREFIX+fused%3A+%3Chttp%3A%2F%2Ftest.edu%2Fvocab%2F%3E%0D%0A%0D%0ASELECT+SAMPLE%28%3Ft%29+%3Fsuper+%3Fsub+%28count%28%3Fmid%29+as+%3Fdistance%29%0D%0AWHERE+%7B%0D%0A++++++++%7B+SELECT+distinct+%3Fsuper%0D%0A++++++++++WHERE+%7B+%3Fx+fused%3AgetInfectedBy+%3Fsuper+%7D%0D%0A++++++++%7D%0D%0A%0D%0A+++++++%3Fmid+fused%3AgetInfectedBy*+%3Fsuper.%0D%0A+++++++%3Fsub+fused%3AgetInfectedBy%2B+%3Fmid.%0D%0A+++++++%7D%0D%0AGROUP+BY+%3Fsuper+%3Fsub%0D%0AORDER+BY+%3Fsuper+%3Fsub%0D%0ALIMIT+1&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=30000 -- empty solution as would be expected. Unhatch " Strict checking of void variables" check-box in the SPARQL Query Editor. -- Regards, Kingsley Idehen Founder & CEO OpenLink Software (Home Page: http://www.openlinksw.com) Weblogs (Blogs): Legacy Blog: http://www.openlinksw.com/blog/~kidehen/ Blogspot Blog: http://kidehen.blogspot.com Medium Blog: https://medium.com/@kidehen Profile Pages: Pinterest: https://www.pinterest.com/kidehen/ Quora: https://www.quora.com/profile/Kingsley-Uyi-Idehen Twitter: https://twitter.com/kidehen Google+: https://plus.google.com/+KingsleyIdehen/about LinkedIn: http://www.linkedin.com/in/kidehen Web Identities (WebID): Personal: http://kingsley.idehen.net/dataspace/person/kidehen#this : http://id.myopenlink.net/DAV/home/KingsleyUyiIdehen/Public/kingsley.ttl#this
smime.p7s
Description: S/MIME Cryptographic Signature
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Virtuoso-users mailing list Virtuoso-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/virtuoso-users