eclipse-rdf4j / rdf4j

Eclipse RDF4J: scalable RDF for Java
https://rdf4j.org/
BSD 3-Clause "New" or "Revised" License
367 stars 164 forks source link

SHACL - Allow shapes to specify if they should be validated as transactional, legacy bulk or sparql bulk #5170

Open hmottestad opened 3 weeks ago

hmottestad commented 3 weeks ago

The SHACL engine usually decides how a shape should be validated based on what operations are in the transaction and the size of the transaction.

It would also be good to limit what the SHACL engine is allowed to do for a particular shape, in case there is an issue with a particular approach.

Something like:

@prefix ex: <http://example.com/ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf4j: <http://rdf4j.org/schema/rdf4j#> .
@prefix rsx: <http://rdf4j.org/shacl-extensions#> .

{
  ex:PersonShape a sh:NodeShape;
    sh:targetClass ex:Person;

    rsx:validationApproach (
        rsx:transactionalValidationApproach
        rsx:sparqlBulkValidationApproach
        rsx:legacyBulkValidationApproach 
    );

    sh:property [
        sh:path (ex:knows1 ex:knows2);
        sh:class ex:Person
      ] .
  rdf4j:nil sh:shapesGraph rdf4j:nil.

}

Where rsx:validationApproach specifies which validation approaches that are available to the SHACL engine.

The order of the items in the list are the preferred order and the SHACL engine must choose the first validation approach that is possible to use.

All shapes support transactional validation and legacy bulk validation. A transaction that adds or modifies a shape must always use a bulk validation. So the following rules apply:

Default

 rsx:validationApproach (
        rsx:transactionalValidationApproach
        rsx:sparqlBulkValidationApproach
        rsx:legacyBulkValidationApproach 
    );

Never use the transactional approach, only bulk

 rsx:validationApproach (
        rsx:sparqlBulkValidationApproach
        rsx:legacyBulkValidationApproach 
    );

Never use the transactional approach, only bulk, and only the legacy bulk approach

 rsx:validationApproach (
        rsx:legacyBulkValidationApproach 
    );

If bulk validation is required, only use the legacy approach and not SPARQL

 rsx:validationApproach (
        rsx:transactionalValidationApproach
        rsx:legacyBulkValidationApproach 
    );

The following are illegal

 rsx:validationApproach (
        rsx:transactionalValidationApproach
    );
 rsx:validationApproach (
        rsx:sparqlBulkValidationApproach
    );
 rsx:validationApproach (
        rsx:transactionalValidationApproach
        rsx:sparqlBulkValidationApproach
    );