-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SHACL advanced targeting #2017
Comments
@hmottestad, I believe you are also interested in the Advanced features, what's your take on this one - do you think we'll be able to get decent performance for SPARQL targeting? |
I believe it will not be possible to get good performance from sparql based targets when there are many targets in the underlying database. Sparql queries are very advanced, and this complexity will likely mean that the query will need to run against the entire database for every transaction. |
Related to #1912 |
As for the option of extending the SHACL specification with our own features, I think that this is in general a bad idea. The issue is that there is a standard for SHACL, and anything we add to that standard will decrease interoperability for our users. I have seen some use cases for extending the SHACL spec before. Coming from a relational database background I have noticed that SHACL doesn't have any way of specifying a "key" for something. A good example of this is: Every ex:User is unique by their ex:username. Performance wise, your solution with being able to specify which predicate represents "rdf:type", should bring no performance penalty. Your example which uses example:type makes me think that a simple rdfs:subPropertyOf relation should handle that well. There is already a small backwards-chaining reasoner built into the ShaclSail, maybe it can be extended. Do you have an example where using ?pred rdfs:subPropertyOf rdf:type would not be advisable? |
I can't find a realistic example where it is inadvisable for the purposes of validation. There is a caveat for plain SPARQL, though.
Now, with inference, my understanding is that if we select objects by So, the |
Yes, that would be true. So if you wanted two shapes, one for The scenario would then be:
With |
In theory, yes, it is a problem with validation as well, since we'll then select both In practice, for the particular use case which I'm working on, there are disambiguation tools which would block the same type |
Have you tried posting your problem to the SHACL mailing list? https://lists.w3.org/Archives/Public/public-shacl/ Maybe they have some opinion or tips for how this should be validated. |
In my opinion quite often one distinguishes node shapes not by rdf:type but by some other field, eg role, position, dct:type, or some other business type. |
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
…cate-object-targets Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
Here is another option that I figured out:
Would fail validation on this example data:
At the moment this kind of construct is not supported by the ShaclSail because we don't allow to nest sh:property like this. |
From some discussion on the SHACL mailing list I was told of a shape filter concept that was part of an earlier SHACL draft. https://www.w3.org/TR/2016/WD-shacl-20160814/#filterShape Issue with that would be to be that it still requires a target. |
This is filter shapes:
I was thinking of using this concept, but combined with the SHACL Advanced custom targetting system.
And for multiple types
And we could even support aggregation.
|
Equivalent to:
|
Branching off to have a proper targetShape on top of propertyShape and nodeShape will make some rather complicated scenarios both possible and efficient. Offers a lot of the functionality which an average SPARQL targeting method would have without the major performance penalty. I'm surprised it wasn't left as part of the spec to begin with. |
I did a bit of testing in the code base to figure out what the current semantics of the An example of how For a target like this:
We would analyze the added statements for matching "sub" targets. Eg. we could end up matching
and
These queries would then have to run against the base sail. We could probably get away with running a single query and using values. The effective result could be that This way we use knowledge from transaction to reduce the number of targets to validate and we wouldn't have to revalidate other red paprikas already in the base sail. |
…AllSubjectsTarget in order to support the filter structure Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
To sum up this issue: sh:filterShape is the chosen method to implement advanced targeting. sh:filterShape was an early feature in the SHACL spec, but was removed. It allows the user to specify a shape to filter the target nodes. Combined with dash:AllSubjects this allows us to have most of the features that the SPARQL targets supply, but with much better performance. |
…cate-object-targets
…cate-object-targets
…cate-object-targets
* GH-2017 initial test case and implementation Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * more test cases Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * GH-1912 initial sparql target support Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * better support for sparql targets Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * GH-1912 better support for sparql targets Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * test Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * more sparql target tests Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * fixed typo Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * change targetClass to targetObject for new compound targetting Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * benchmark Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * fix supported features docs Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * Trigger GitHub ci * improved benchmarks Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * GH-2017 introduce support for dash:AllObjectsTarget and AllSubjectsTarget in order to support the filter structure Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * GH-2017 initial support for filter shapes Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * fix up tests Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * cleanup Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * fix dash vocab file Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * fix after merge Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * refactoring to better handle target filters Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * merge fixes Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * Support for dash constants for dash:AllSubjects and dash:AllObjects Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * refactored code Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * final code for toggle for experimental filter shapes Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * added test cases for sh:hasValue Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * more test cases for hasValue and also fix for empty sh:and, sh:or, sh:not Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * moving shapes back where they came from, will do the bigger refactor in the new AST branch Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * code cleanup Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * support for sh:hasValue Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * more javadocs Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * remove unused tests Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * some simplification and docs Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * fixed headers and more tests Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * fix tests and some code cleanup Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * code cleanup Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * initial support for dash:valuesIn Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * bechmark Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * migrate to sh:targetShape Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * a couple of tests for negation Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * test cases for value in Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * more tests for targetNode Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * added some benchmarks Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * implemented handling of node validation Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * functional implementation for valuesIn Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * more fixes Signed-off-by: Håvard Ottestad <hmottestad@gmail.com> * switched naming of new features Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
Ended up back with sh:targetShape. |
…agreed on the shacl mailing list Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
… shacl mailing list (#2355) Signed-off-by: Håvard Ottestad <hmottestad@gmail.com>
At the moment, the SHACL targeting system has some limitations. Assume that we have the following data:
We want to be able to target
ObjA-1
andObjA-2
.sh:targetNode
works forObjA-1
andObjA-2
, but suppose we want to insertObjA-3
.sh:targetClass
is hardcoded to work withrdf:type
and we are usingexample:type
instead.sh:targetSubjectsOf
forexample:type
will also selectObjB-1
.rdf:Type
.The simple workaround is to force
rdf:type
to always be the class differntiator. It is possible, however, that some users may not want to do that - for example, they may be using types for two different systems and have to differentiate between them.There are two potential resolutions I see:
This is less powerful, but looks like it will be more performant. There is the added drawback that it is not part of the specification.
Any way to have non-standard targeting for the use case would be good.
Are there any other options that I'm missing? Or is SHACL Advanced and/or the extneded spec workaround the way to go?
The text was updated successfully, but these errors were encountered: