Hi,

my colleague Ignacio (CCed) has found a possible bug at Virtuoso's
SPARQL query engine about OPTIONAL patterns.

He is trying to execute this query [1] over this endpoint [2], but
results change depending of the order of the OPTIONAL patterns:

1) The first query that he wrote [3]:

        SELECT ?source ?section ?homepage
        FROM <http://data.fundacionctic.org/idi/debian> 
        WHERE {
        ?source <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://idi.fundacionctic.org/steamy/debian.owl#Source> .
        ?source <http://idi.fundacionctic.org/steamy/debian.owl#packageName> 
?sourcename .
        OPTIONAL { ?source 
<http://idi.fundacionctic.org/steamy/debian.owl#section> ?section }
        OPTIONAL { ?source <http://xmlns.com/foaf/0.1/page> ?homepage }
        FILTER(regex(?sourcename,"vim","i"))
        }

2) Switching the order of the optional patterns [4]:

        SELECT ?source ?section ?homepage
        FROM <http://data.fundacionctic.org/idi/debian> 
        WHERE {
        ?source <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://idi.fundacionctic.org/steamy/debian.owl#Source> .
        ?source <http://idi.fundacionctic.org/steamy/debian.owl#packageName> 
?sourcename .
        OPTIONAL { ?source <http://xmlns.com/foaf/0.1/page> ?homepage }
        OPTIONAL { ?source 
<http://idi.fundacionctic.org/steamy/debian.owl#section> ?section }
        FILTER(regex(?sourcename,"vim","i"))
        }

The results are the same, but the second query doesn't return their
section is some cases. And I don't really know why... because SPARQL's
specification literally says that "if the optional part does not match,
it creates no bindings but does not eliminate the solution".

Our inquiries lead us to a problem relative on how FILTER patterns
applies to OPTIONAL patterns (second query only returns results where
their homepage contains the substring "vim"). But that violates how is
the scope of FILTERS in SPARQL [6]. So I'm not really sure what's
actually the problem...

The query is running over an instances Virtuoso OSE 5.0.11 on Debian
GNU/Linux. Right now we don't have deployed any latest version of
Virtuoso; but you can reproduce the bug getting the whole graph [7] with
a construct query.

Best regards,

[1] http://paste.debian.net/hidden/62c4e7e1/ 
[2] http://data.fundacionctic.org/sparql
[3] http://tinyurl.com/virtuoso-bug-optional-1
[4] http://tinyurl.com/virtuoso-bug-optional-2 
[5] http://www.w3.org/TR/rdf-sparql-query/#optionals 
[6] http://www.w3.org/TR/rdf-sparql-query/#scopeFilters 
[7] http://data.fundacionctic.org/idi/debian 

-- 
Sergio Fernández
CTIC - Technological Center
Parque Científico y Tecnológico de Gijón
C/ Ada Byron, 39 Edificio Centros Tecnológicos
33203 Gijón - Asturias - Spain
Tel.: +34 984 29 12 12
Fax: +34 984 39 06 12
E-mail: [email protected]
http://www.fundacionctic.org
Privacy Policy: http://www.fundacionctic.org/privacidad


Reply via email to