Reputation: 511
Using GraphDB, I see the following behavior in an OWL2-RL optimized repo. Probably I’m doing something wrong... but I fail to see what. Probably not specific to GraphDB, but generic SPARQL question.
Full repo contents:
PREFIX owl: http://www.w3.org/2002/07/owl#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
PREFIX xsd: http://www.w3.org/2001/XMLSchema#
PREFIX : https://testontology#
insert data {
graph <https://graph/ontology> {
:objectProp1 a owl:ObjectProperty;
rdfs:range owl:Thing;
:ingestionName "objectProp1".
:objectProp2 a owl:ObjectProperty;
rdfs:range owl:Thing;
:ingestionName "objectProp2".
:dataProp1 a owl:DatatypeProperty;
rdfs:range owl:Thing;
:ingestionName "dataProp1".
:dataProp2 a owl:DatatypeProperty;
rdfs:range owl:Thing;
:ingestionName "dataProp2".
}
}
Query (I'm not suggesting this is a good query approach, just trying to get it explained...):
PREFIX : https://testontology#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
PREFIX owl: http://www.w3.org/2002/07/owl#
PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
select * where {
?propertyIRI :ingestionName ?ingestionName.
optional {
?propertyIRI a owl:DatatypeProperty.
BIND( "ABC" as ?isDataProp_flag )
}
BIND(BOUND(?isDataProp_flag) as ?isDataProp)
}
Response:
Question: I don’t understand result row 3… The isDataProp_flag has some value, so BOUND should return true, no?
When requesting GraphDB's query plan, I see the BIND statement has been moved:
Questions:
At the end of the explanation, graphdb says that the optimization groups are handled in the order specified. That would mean the isDataProp_Flag would never be bound at the moment of the first bind statement, would it? So isDataprop should always return false as a consequence. That does not happen.
Why is GraphDB allowed to move the BIND before the optional statement? That would be ok if the BIND in the optional could not influence the result, but that one will be (not) bound depending on the evaluation of the optional. So I would guess that the BIND(BOUND(… may only be moved earlier if its result cannot depend on the optional.
For clarity, a more appropriate way to obtain the same would be:
PREFIX : https://testontology#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
PREFIX owl: http://www.w3.org/2002/07/owl#
PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
select ?propertyIRI ?isDataProp where {
?propertyIRI :ingestionName ?ingestionName.
BIND(EXISTS {?propertyIRI a owl:DatatypeProperty} as ?isDataProp)
}
The latter query works as expected.
Upvotes: 2
Views: 47