Modify an existing TripleMap

Hello!
I tryng to modify an existing TripleMap, adding a new predicateObjectMap, but I recive the error.

SQLState: 37000

Message: SQ074: Line 158: SP031: SPARQL compiler: The statement contains two identical declarations of mappings

I started executing this R2RML:
(Creation of Work (TriplesMapGSDRB_SCHEDA_RB), Instance(TriplesMapGSDRB_SUB_CDE) and relation between Work—>>>Instance and Work<<<—Instance

SPARQL
prefix rr: <http://www.w3.org/ns/r2rml#> 
prefix DBTEST: <http://localhost:8890/schemas/DBTEST/> 
prefix dbtest-stat: <http://localhost:8890/DBTEST/stat#> 
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
prefix void: <http://rdfs.org/ns/void#> 
prefix scovo: <http://purl.org/NET/scovo#> 
prefix aowl: <http://bblfish.net/work/atom-owl/2006-06-06/> 
prefix foaf: <http://xmlns.com/foaf/0.1/> 
prefix bf: <http://id.loc.gov/ontologies/bibframe/> 


INSERT { GRAPH <urn:dbtest:tables:r2rml:mappings>
{ 
<#TriplesMapGSDRB_SCHEDA_RB> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "DBTEST" ; rr:tableOwner "DBA" ; rr:tableName "GSDRB_SCHEDA_RB" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://localhost:8890/DBTEST/work/{ID_CATALOGO}#this"; rr:class bf:Work ; rr:graph <http://localhost:8890/DBTEST#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:id_catalogo ] ; rr:objectMap [ rr:column "ID_CATALOGO" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:tsk ] ; rr:objectMap [ rr:column "TSK" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:oss ] ; rr:objectMap [ rr:column "OSS" ]; ] ;
rr:predicateObjectMap 
  [ rr:predicateMap 
      [ rr:constant bf:hasInstance ] ; 
    rr:objectMap 
      [ rr:parentTriplesMap <#TriplesMapGSDRB_SUB_CDE>;  
        rr:joinCondition 
          [ rr:child "ID_CATALOGO" ; 
            rr:parent "REF_CATALOGO" 
          ] ; 
      ]; 
  ] .

<#TriplesMapGSDRB_SUB_CDE> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "DBTEST" ; rr:tableOwner "DBA" ; rr:tableName "GSDRB_SUB_CDE" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://localhost:8890/DBTEST/instance/{SUBCOUNTER}#this"; rr:class bf:Instance; rr:graph <http://localhost:8890/DBTEST#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:subcounter ] ; rr:objectMap [ rr:column "SUBCOUNTER" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:ref_catalogo ] ; rr:objectMap [ rr:column "REF_CATALOGO" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:cdep ] ; rr:objectMap [ rr:column "CDEP" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:cdef ] ; rr:objectMap [ rr:column "CDEF" ]; ] ;
rr:predicateObjectMap 
  [ rr:predicateMap 
      [ rr:constant bf:instanceOf ] ; 
    rr:objectMap 
      [ rr:parentTriplesMap <#TriplesMapGSDRB_SCHEDA_RB>;  
        rr:joinCondition 
          [ rr:child "REF_CATALOGO" ; 
            rr:parent "ID_CATALOGO" 
          ] ; 
      ]; 
  ] .

  }

};

-- Generate & Execute Virtual RDF Views 
-- from R2RML mappings
EXEC ('SPARQL ' || DB.DBA.R2RML_MAKE_QM_FROM_G ('urn:dbtest:tables:r2rml:mappings'));

Then i added a new piece of R2RML code.
The creation of Item (TriplesMapGSDRB_SUB_CP) related to Instance(TriplesMapGSDRB_SUB_CDE):

-- R2RML GRAPH
-- Load R2RML script
-- Creation node Item e arc Item->Instance

SPARQL
prefix rr: <http://www.w3.org/ns/r2rml#> 
prefix DBTEST: <http://localhost:8890/schemas/DBTEST/> 
prefix dbtest-stat: <http://localhost:8890/DBTEST/stat#> 
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
prefix void: <http://rdfs.org/ns/void#> 
prefix scovo: <http://purl.org/NET/scovo#> 
prefix aowl: <http://bblfish.net/work/atom-owl/2006-06-06/> 
prefix foaf: <http://xmlns.com/foaf/0.1/> 
prefix bf: <http://id.loc.gov/ontologies/bibframe/> 


INSERT { GRAPH <urn:dbtest:tables:r2rml:mappings>
{ 
<#TriplesMapGSDRB_SUB_CP> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "DBTEST" ; rr:tableOwner "DBA" ; rr:tableName "GSDRB_SUB_CP" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://localhost:8890/DBTEST/item/{SUBCOUNTER}#this"; rr:class bf:Item; rr:graph <http://localhost:8890/DBTEST#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:subcounter ] ; rr:objectMap [ rr:column "SUBCOUNTER" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:ref_catalogo ] ; rr:objectMap [ rr:column "REF_CATALOGO" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:cpzo ] ; rr:objectMap [ rr:column "CPZO" ]; ] ;
rr:predicateObjectMap 
  [ rr:predicateMap 
      [ rr:constant bf:itemOf ] ; 
    rr:objectMap 
      [ rr:parentTriplesMap <#TriplesMapGSDRB_SUB_CDE>;  
        rr:joinCondition 
          [ rr:child "REF_CATALOGO" ; 
            rr:parent "REF_CATALOGO" 
          ] ; 
      ]; 
  ] .

  }

};

-- Generate & Execute Virtual RDF Views 
-- from R2RML mappings
EXEC ('SPARQL ' || DB.DBA.R2RML_MAKE_QM_FROM_G ('urn:dbtest:tables:r2rml:mappings'));

Up to this point everything worked fine.

After that I attempted to modify the TriplesMapGSDRB_SUB_CDE, that is my class bf:Instance, trying to add a new relationship between Instance—>>>Item (the join with TriplesMapGSDRB_SUB_CP)

SPARQL
prefix rr: <http://www.w3.org/ns/r2rml#> 
prefix DBTEST: <http://localhost:8890/schemas/DBTEST/> 
prefix dbtest-stat: <http://localhost:8890/DBTEST/stat#> 
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
prefix void: <http://rdfs.org/ns/void#> 
prefix scovo: <http://purl.org/NET/scovo#> 
prefix aowl: <http://bblfish.net/work/atom-owl/2006-06-06/> 
prefix foaf: <http://xmlns.com/foaf/0.1/> 
prefix bf: <http://id.loc.gov/ontologies/bibframe/> 


INSERT { GRAPH <urn:dbtest:tables:r2rml:mappings>
{ 

<#TriplesMapGSDRB_SUB_CDE> a rr:TriplesMap; rr:logicalTable [ rr:tableSchema "DBTEST" ; rr:tableOwner "DBA" ; rr:tableName "GSDRB_SUB_CDE" ]; 
rr:subjectMap [ rr:termType rr:IRI  ; rr:template "http://localhost:8890/DBTEST/instance/{SUBCOUNTER}#this"; rr:class bf:Instance; rr:graph <http://localhost:8890/DBTEST#> ];
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:subcounter ] ; rr:objectMap [ rr:column "SUBCOUNTER" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:ref_catalogo ] ; rr:objectMap [ rr:column "REF_CATALOGO" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:cdep ] ; rr:objectMap [ rr:column "CDEP" ]; ] ;
rr:predicateObjectMap [ rr:predicateMap [ rr:constant DBTEST:cdef ] ; rr:objectMap [ rr:column "CDEF" ]; ] ;
rr:predicateObjectMap 
  [ rr:predicateMap 
      [ rr:constant bf:instanceOf ] ; 
    rr:objectMap 
      [ rr:parentTriplesMap <#TriplesMapGSDRB_SCHEDA_RB>;  
        rr:joinCondition 
          [ rr:child "REF_CATALOGO" ; 
            rr:parent "ID_CATALOGO" 
          ] ; 
      ]; 
  ] ;
  rr:predicateObjectMap 
  [ rr:predicateMap 
      [ rr:constant bf:hasItem ] ; 
    rr:objectMap 
      [ rr:parentTriplesMap <#TriplesMapGSDRB_SUB_CP>;  
        rr:joinCondition 
          [ rr:child "REF_CATALOGO" ; 
            rr:parent "REF_CATALOGO" 
          ] ; 
      ]; 
  ] .

  }

};

-- Generate & Execute Virtual RDF Views 
-- from R2RML mappings
EXEC ('SPARQL ' || DB.DBA.R2RML_MAKE_QM_FROM_G ('urn:dbtest:tables:r2rml:mappings'));

But I recive the error:

There is a way to modify (or delete and recreate) a TriplesMap (in my case the TriplesMapGSDRB_SUB_CDE) without getting similar errors?

I hope I clearly described what I did, the problem and what I would like to achieve.

You’ve altered the original R2RML graph that’s used that generates the final Virtuoso Quad Map, hence the error that you are experiencing.

Here’s how the system works:

  1. You create R2RML by hand or generate it via the R2RML Wizard
  2. Generated R2RML is used to generated Virtuoso Quad Maps (each mapping is a view definition)

If you change your R2RML by hand you will also need to drop its associated Quad Map(s).

Finding Existing Quad Maps

Via SPARQL Query Service Endpoint

You can obtain a list of Quad Maps using the following URL pattern:
http[s]://{cname}/rdfviews.vsp

Finding Quad Maps via a SPARQL Query

SPARQL
PREFIX virtrdf: <http://www.openlinksw.com/schemas/virtrdf#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT  ?s2 AS ?sqlTable 
                 ?s1 AS ?rdfQuadMap
                 ?s6 AS ?rdfSubjectURITemplate
                 ?s3 AS ?rdfPredicate 
                 ?s10 AS ?rdfObjectValue
                 ?s8 AS ?rdfObjectDataType
WHERE 
 {
   ?s1  a virtrdf:QuadMap .
   ?s1  virtrdf:qmTableName ?s2 .
   ?s1  virtrdf:qmPredicateRange-rvrFixedValue ?s3 . 
   ?s1  virtrdf:qmSubjectMap ?s4 .
   ?s4  virtrdf:qmvFormat ?s5 .
   ?s5  virtrdf:qmfCustomString1 ?s6 .
   ?s1  virtrdf:qmObjectMap ?s7 .
   ?s7  virtrdf:qmvFormat ?s8 .
   ?s7  virtrdf:qmvColumns ?s9 .
   ?s9  rdf:_1 ?s10          
   FILTER (CONTAINS(STR(?s2),'sqlquery') AND CONTAINS(STR(?s2),'FROM "Demo"."demo"."suppliers"') )
} ;

Dropping a Quad Map

SPARQL DROP QUAD MAP <urn:demo:tables:r2rml:mappings> ;

Related