Page MenuHomePhabricator

Add the different constraint statuses in RDF
Closed, InvalidPublic

Description

Wikidata constraints now have 3 different levels: mandatory, ordinary and suggestion. These levels don't appear in RDF dumps, therefore they cannot be queried. For example, in this query, it should be possible to exclude the suggestion constraints, or to query only the suggestion constraints, etc.

Event Timeline

We could define three new predicates to link statements to constraints only if the constraint status matches that predicate, either in addition to the existing wikibase:hasViolationForConstraint predicate (which would continue to link statements to constraints for violations of any status), or replacing it (though this would break existing queries).

I’m struggling to find a good name for the middle predicate, though, because I don’t think we have a good name for the default status. The items are “mandatory constraint”, (none) and “suggestion constraint”; internally, the statuses are violation, warning and suggestion, but if we use violation directly that collides with the existing predicate.

wikibase:has{MandatoryViolation,Warning,Suggestion}ForConstraint would work, but feels odd to me. Thoughts?

Where constraint violation level is specified? If it's a property of constraint itself, there should be a way to query it already. Or is it stored outside the constraint statement? I am not completely familiar with this part, would appreciate explanations or reference to the docs.

Smalyshev triaged this task as Medium priority.May 10 2019, 7:40 PM

We could define three new predicates to link statements to constraints only if the constraint status matches that predicate, either in addition to the existing wikibase:hasViolationForConstraint predicate (which would continue to link statements to constraints for violations of any status), or replacing it (though this would break existing queries).

I’m struggling to find a good name for the middle predicate, though, because I don’t think we have a good name for the default status. The items are “mandatory constraint”, (none) and “suggestion constraint”; internally, the statuses are violation, warning and suggestion, but if we use violation directly that collides with the existing predicate.

wikibase:has{MandatoryViolation,Warning,Suggestion}ForConstraint would work, but feels odd to me. Thoughts?

Related: T220028#5095253. Please feel free to copy/move/adapt/discuss/reject anything.

Where constraint violation level is specified? If it's a property of constraint itself, there should be a way to query it already. Or is it stored outside the constraint statement? I am not completely familiar with this part, would appreciate explanations or reference to the docs.

🤦 you’re completely right, it’s a property of the constraint (constraint status qualifier on the constraint statement) and therefore can be queried. No idea why I didn’t realize that before. @Harmonia_Amanda, I think what you need is this:

SELECT ?property ?propertyLabel ?constraintTypeLabel ?item ?itemLabel WHERE {
  ?item ?linksTo wd:Q38108;
        ?p ?statement.
  ?statement wikibase:hasViolationForConstraint ?constraint.
  ?property wikibase:claim ?p;
            p:P2302 ?constraint.
  ?constraint ps:P2302 ?constraintType.
  MINUS { ?constraint pq:P2316 wd:Q62026391. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?property

Try it!

I guess so – I think “invalid” is the most fitting status given that this was already possible (though it took us a while to realize it).