bug in executing SPARQL queries

0 views
Skip to first unread message

Eloy Retamino Carrion

unread,
Nov 9, 2016, 12:32:42 PM11/9/16
to Stardog
Hello,

I have localized what seems to be a bug in stardog.

Given the next ontology:

@prefix : <http://www.semanticweb.org/eloy/ontologies/2016/10/untitled-ontology-9#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.semanticweb.org/eloy/ontologies/2016/10/untitled-ontology-9> .

<http://www.semanticweb.org/eloy/ontologies/2016/10/untitled-ontology-9> rdf:type owl:Ontology .

:A rdf:type owl:Class .
:B rdf:type owl:Class .

:a rdf:type owl:NamedIndividual ,
           
:A .

:b rdf:type owl:NamedIndividual ,
           
:B .

when executing the next query:

prefix : <http://www.semanticweb.org/eloy/ontologies/2016/10/untitled-ontology-9#>

select ?x ?y where
{  
   
?y a :B .
 
   
{ ?x a :A .
    FILTER EXISTS
{ ?y a :A } }
}


results are x = :a, y = :b

if I change EXISTS for NOT EXISTS no bindings are found.

ie. EXISTS is showing the opposite behavior as expected. If I remove the braces the results are correct.

This just happens in certain circumstances, which I haven't completely figured out.

SUMMARY: EXISTS shows inverse behavior when in braces in certain circumstances. This is a problem when using UNION, OPTIONAL, MINUS or in any other case which require using sub graph patterns.

Regards,
Eloy.

Evren Sirin

unread,
Nov 9, 2016, 9:39:50 PM11/9/16
to Stardog
This is the expected behavior based on the SPARQL semantics; see scope
of filters [1]. The meaning of your query changes when you put the
extra grouping. First this group in your query is answered:

{ ?x a :A . FILTER EXISTS { ?y a :A } }

This will bind ?x to :a and FILTER will be satisfied due to :b but
FILTER does not bind variables. Then this solution (x = :a) will be
joined with the solution for the outer triple pattern yielding x = :a,
y = :b.

Best,
Evren

[1] https://www.w3.org/TR/sparql11-query/#scopeFilters
> --
> -- --
> You received this message because you are subscribed to the C&P "Stardog"
> group.
> To post to this group, send email to sta...@clarkparsia.com
> To unsubscribe from this group, send email to
> stardog+u...@clarkparsia.com
> For more options, visit this group at
> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Eloy Retamino Carrion

unread,
Nov 10, 2016, 3:02:53 AM11/10/16
to Stardog
Thanks for the explanation! sorry I posted it as a bug.
Reply all
Reply to author
Forward
0 new messages