openlink / virtuoso-opensource

Virtuoso is a high-performance and scalable Multi-Model RDBMS, Data Integration Middleware, Linked Data Deployment, and HTTP Application Server Platform
https://vos.openlinksw.com
Other
853 stars 211 forks source link

"graph" leads to inconsistent results of property path query. #1078

Open slater2022 opened 1 year ago

slater2022 commented 1 year ago
$ ./virtuoso-t -?
Virtuoso Open Source Edition (Column Store) (multi threaded)
Version 7.2.7.3234-pthreads as of May 18 2022 (67261301a)
Compiled for Linux (x86_64-generic_glibc25-linux-gnu)
Copyright (C) 1998-2022 OpenLink Software

use only the original data. query 1:

select distinct  ?s
where {
    graph ?g {
        ?s rdfs:subClassOf?/a rdfs:Class.
    }
}

query result:

s
--
http://www.w3.org/2002/07/owl#Restriction
http://www.w3.org/2002/07/owl#TransitiveProperty
http://www.w3.org/2002/07/owl#SymmetricProperty
http://www.w3.org/2002/07/owl#InverseFunctionalProperty

query 2:

select distinct  ?s
where {
    ?s rdfs:subClassOf?/a rdfs:Class.
}

query result:

s
--
http://www.w3.org/2002/07/owl#InverseFunctionalProperty
http://www.w3.org/2002/07/owl#SymmetricProperty
http://www.w3.org/2002/07/owl#FunctionalProperty
http://www.w3.org/2002/07/owl#TransitiveProperty
http://www.w3.org/2002/07/owl#Class
http://www.w3.org/2002/07/owl#Restriction
http://www.w3.org/2002/07/owl#Ontology
http://www.w3.org/2002/07/owl#OntologyProperty
http://www.w3.org/2002/07/owl#AnnotationProperty
http://www.w3.org/2002/07/owl#AllDifferent
http://www.w3.org/2002/07/owl#ObjectProperty
http://www.w3.org/2002/07/owl#DatatypeProperty
http://www.w3.org/2002/07/owl#DeprecatedClass
http://www.w3.org/2002/07/owl#DeprecatedProperty
http://www.w3.org/2002/07/owl#DataRange

The results of the two queries are different

imitko commented 1 year ago

@slater2022

Not a bug. When you use graph ?g { ... }, this means triple patterns inside are belong to same graph, therefore you do not query across all graphs. Note Virtuoso RDF store is a QUAD store, not a triple store.

HTH

slater2022 commented 1 year ago

query

select distinct  ?s
where {
    graph ?g {
        ?s a rdfs:Class.
    }
}

query result

s
--
http://www.w3.org/2002/07/owl#InverseFunctionalProperty
http://www.w3.org/2002/07/owl#SymmetricProperty
http://www.w3.org/2002/07/owl#FunctionalProperty
http://www.w3.org/2002/07/owl#TransitiveProperty
http://www.w3.org/2002/07/owl#Class
http://www.w3.org/2002/07/owl#Ontology
http://www.w3.org/2002/07/owl#OntologyProperty
http://www.w3.org/2002/07/owl#AnnotationProperty
http://www.w3.org/2002/07/owl#AllDifferent
http://www.w3.org/2002/07/owl#Restriction
http://www.w3.org/2002/07/owl#ObjectProperty
http://www.w3.org/2002/07/owl#DatatypeProperty
http://www.w3.org/2002/07/owl#DeprecatedClass
http://www.w3.org/2002/07/owl#DeprecatedProperty
http://www.w3.org/2002/07/owl#DataRange

The query result is the same as query 2

SPARQL 1.1 Query Language

elt? | ZeroOrOnePath | A path that connects the subject and object of the path by zero or one matches of elt. -- | -- | --

no path matching zero rdfs:subClassOf

TallTed commented 1 year ago

@imitko — Please take a look at @slater2022's followup...