OpenLink Virtuoso
Version: 07.20.3241
Build: May 21 2025 (bae7c13af8)
The following select returns four records, two of them are identical
(dataset provided)
SELECT distinct * from http://example/graph/Example_1 WHERE {
?r_type rdfs:subPropertyOf* http://example/property/positive .
?r rdf:type ?r_type .
?r http://example/property/reference ?ref .
?ref http://example/property/partOf ?doc .
?s ?r ?o .
?o rdf:type ?o_type .
optional{ ?doc http://example/property/startTime ?startTime . }
filter (?s = http://example/resource/P_1) }
Strangely enough any of the following lines removed will prevent the doubles:
?o rdf:type ?o_type .
optional{ ?doc http://example/property/startTime ?startTime . }
I presume the error occurs due to the SELECT cost and could be resolved by settings change.
Any advise will be appreciated.
Dataset TTL
@prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# .
@prefix ns1: http://example/property/ .
ns1:partOf rdf:type rdf:Property .
ns1:startTime rdf:type rdf:Property .
@prefix ns2: http://example/resource/ .
@prefix ns3: http://example/ontology/ .
ns2:P_1 rdf:type ns3:Person .
@prefix rdfs: http://www.w3.org/2000/01/rdf-schema# .
ns3:Document rdf:type rdfs:Class .
ns3:Organization rdf:type rdfs:Class .
ns3:Person rdf:type rdfs:Class .
ns3:Reference rdf:type rdfs:Class .
ns1:r_1 rdf:type ns1:related .
ns1:r_2 rdf:type ns1:positive .
ns1:r_3 rdf:type ns1:related .
ns1:reference rdf:type rdf:Property .
ns1:relation rdf:type rdf:Property .
ns2:Ref_1 rdf:type ns3:Reference .
ns2:Ref_2 rdf:type ns3:Reference .
ns2:Ref_3 rdf:type ns3:Reference .
ns3:Location rdf:type rdfs:Class .
ns2:O_1 rdf:type ns3:Organization .
ns2:O_2 rdf:type ns3:Organization .
ns2:D_1 rdf:type ns3:Document .
ns2:D_2 rdf:type ns3:Document .
ns2:D_3 rdf:type ns3:Document .
ns2:L_1 rdf:type ns3:Location .
ns1:positive rdfs:subPropertyOf ns1:relation .
ns1:related rdfs:subPropertyOf ns1:positive .
ns2:Ref_1 ns1:partOf ns2:D_1 .
ns2:Ref_2 ns1:partOf ns2:D_2 .
ns2:Ref_3 ns1:partOf ns2:D_3 .
ns2:D_2 ns1:startTime ns2:T_1 .
ns2:D_3 ns1:startTime ns2:T_2 .
ns2:P_1 ns1:r_1 ns2:O_1 ;
ns1:r_2 ns2:O_2 ;
ns1:r_3 ns2:L_1 .
ns1:r_1 ns1:reference ns2:Ref_1 .
ns1:r_2 ns1:reference ns2:Ref_2 .
ns1:r_3 ns1:reference ns2:Ref_3 .
Dataset NQ
http://example/property/r_1 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/property/related http://example/graph/Example_1 .
http://example/property/r_1 http://example/property/reference http://example/resource/Ref_1 http://example/graph/Example_1 .
http://example/property/r_2 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/property/positive http://example/graph/Example_1 .
http://example/property/r_2 http://example/property/reference http://example/resource/Ref_2 http://example/graph/Example_1 .
http://example/property/r_3 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/property/related http://example/graph/Example_1 .
http://example/property/r_3 http://example/property/reference http://example/resource/Ref_3 http://example/graph/Example_1 .
http://example/resource/D_1 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/ontology/Document http://example/graph/Example_1 .
http://example/resource/D_2 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/ontology/Document http://example/graph/Example_1 .
http://example/resource/D_2 http://example/property/startTime http://example/resource/T_1 http://example/graph/Example_1 .
http://example/resource/D_3 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/ontology/Document http://example/graph/Example_1 .
http://example/resource/D_3 http://example/property/startTime http://example/resource/T_2 http://example/graph/Example_1 .
http://example/resource/O_1 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/ontology/Organization http://example/graph/Example_1 .
http://example/resource/O_2 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/ontology/Organization http://example/graph/Example_1 .
http://example/resource/L_1 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/ontology/Location http://example/graph/Example_1 .
http://example/resource/P_1 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/ontology/Person http://example/graph/Example_1 .
http://example/resource/P_1 http://example/property/r_1 http://example/resource/O_1 http://example/graph/Example_1 .
http://example/resource/P_1 http://example/property/r_2 http://example/resource/O_2 http://example/graph/Example_1 .
http://example/resource/P_1 http://example/property/r_3 http://example/resource/L_1 http://example/graph/Example_1 .
http://example/resource/Ref_1 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/ontology/Reference http://example/graph/Example_1 .
http://example/resource/Ref_1 http://example/property/partOf http://example/resource/D_1 http://example/graph/Example_1 .
http://example/resource/Ref_2 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/ontology/Reference http://example/graph/Example_1 .
http://example/resource/Ref_2 http://example/property/partOf http://example/resource/D_2 http://example/graph/Example_1 .
http://example/resource/Ref_3 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://example/ontology/Reference http://example/graph/Example_1 .
http://example/resource/Ref_3 http://example/property/partOf http://example/resource/D_3 http://example/graph/Example_1 .
http://example/ontology/Location http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/2000/01/rdf-schema#Class http://example/graph/Example_1 .
http://example/ontology/Organization http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/2000/01/rdf-schema#Class http://example/graph/Example_1 .
http://example/ontology/Person http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/2000/01/rdf-schema#Class http://example/graph/Example_1 .
http://example/ontology/Document http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/2000/01/rdf-schema#Class http://example/graph/Example_1 .
http://example/ontology/Reference http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/2000/01/rdf-schema#Class http://example/graph/Example_1 .
http://example/property/startTime http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/1999/02/22-rdf-syntax-ns#Property http://example/graph/Example_1 .
http://example/property/reference http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/1999/02/22-rdf-syntax-ns#Property http://example/graph/Example_1 .
http://example/property/partOf http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/1999/02/22-rdf-syntax-ns#Property http://example/graph/Example_1 .
http://example/property/relation http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/1999/02/22-rdf-syntax-ns#Property http://example/graph/Example_1 .
http://example/property/positive http://www.w3.org/2000/01/rdf-schema#subPropertyOf http://example/property/relation http://example/graph/Example_1 .
http://example/property/related http://www.w3.org/2000/01/rdf-schema#subPropertyOf http://example/property/positive http://example/graph/Example_1 .

