5 Replies Latest reply on Jan 13, 2014 4:57 PM by alwu-Oracle

    Cannot Create RDF View in R2RML Conversion Example

    Pinar Gocebe

      Hi All,

       

      In a project I want to do a R2RML conversion. I folowed below steps according to 12c Release 1 tutorial.


      1. Create a stage table with below command.

       

      CREATE TABLE stage_table_name(
                           RDF$STC_sub varchar2(4000) not null,
                           RDF$STC_pred varchar2(4000) not null,
                           RDF$STC_obj varchar2(4000) not null,
                           RDF$STC_graph varchar2(4000)
      );
      

       

      2. Grant select and insert this stage table for user MDSYS

       

      GRANT SELECT, INSERT ON STAGETAB TO MDSYS;
      

       

      3. Load r2rml mapping to this stage table with running below java code.

       

      
      Oracle oracle = new Oracle (connectionUrl, user, password);       
      GraphOracleSem graph = new GraphOracleSem(oracle, modelName);
      FileInputStream is = new FileInputStream(mappingFile); 
      graph.getBulkUpdateHandler().prepareBulk(is,//inputstream
            "http://example.com", // base URI
            "TTL", // data file type: can be RDF/XML, N-TRIPLE, etc.
            "rdf_users", // tablespace
            null, // flags
            null, // listener
            stageTableName// staging table name.
            );
      graph.close();
      oracle.dispose();
      

       

      4. Create RDF View with this stage table to execute below command.

       

      BEGIN
      sem_apis.create_rdfview_model(
      model_name => 'rdf_view_name',
      tables => NULL,
      r2rml_table_owner => 'user',
      r2rml_table_name => 'stage_table_name'
      );
      END;
      

       

       

      I performed first 3 steps successfully. Stage table has been created and r2rml mapping has been loaded to this stage table. But in the last step there is an error like this;

       

      [Error] Execution (1: 3): ORA-00904: "CHILDCOL$RDFTERM": invalid identifier

      ORA-06512: at "MDSYS.SDO_RDF_INTERNAL",  line 14308

      ORA-06512: at "MDSYS.SDO_RDF",  line 3616

      ORA-06512: at "MDSYS.RDF_APIS",  line 1253

      ORA-06512: at  line 2

       

      How can I solve this problem?

       

      Thanks

        • 1. Re: Cannot Create RDF View in R2RML Conversion Example
          alwu-Oracle

          Hi,

           

          Are you using the same R2RML in turtle format as described in the dev guide? If not, please cut & paste here the mapping file.

           

          Thanks,


          Zhe Wu

          • 2. Re: Cannot Create RDF View in R2RML Conversion Example
            Pinar Gocebe

            Hi Zhe,

             

            I am using same R2RML mapping which is in the developer guide. it is below.

            @prefix rr: <http://www.w3.org/ns/r2rml#>.
            @prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
            @prefix ex: <http://example.com/ns#>.
            ex:TriplesMap_Dept
            rr:logicalTable [ rr:tableName "DEPT" ];
            rr:subjectMap [
            rr:template "http://data.example.com/department/{DEPTNO}";
            rr:class ex:Department;
            ];
            rr:predicateObjectMap [
            rr:predicate ex:deptNum;
            rr:objectMap [ rr:column "DEPTNO" ; rr:datatype xsd:integer ];
            ];
            rr:predicateObjectMap [
            rr:predicate ex:deptName;
            rr:objectMap [ rr:column "DNAME" ];
            ];
            rr:predicateObjectMap [
            rr:predicate ex:deptLocation;
            rr:objectMap [ rr:column "LOC" ];
            ].
            ex:TriplesMap_Emp
            rr:logicalTable [ rr:tableName "EMP" ];
            rr:subjectMap [
            rr:template "http://data.example.com/employee/{EMPNO}";
            rr:class ex:Employee;
            ];
            rr:predicateObjectMap [
            rr:predicate ex:empNum;
            rr:objectMap [ rr:column "EMPNO" ; rr:datatype xsd:integer ];
            ];
            rr:predicateObjectMap [
            rr:predicate ex:empName;
            rr:objectMap [ rr:column "ENAME" ];
            ];
            rr:predicateObjectMap [
            rr:predicate ex:jobType;
            rr:objectMap [ rr:column "JOB" ];
            ];
            rr:predicateObjectMap [
            rr:predicate ex:worksForDeptNum;
            rr:objectMap [ rr:column "DEPTNO" ; rr:dataType xsd:integer ];
            ];
            rr:predicateObjectMap [
            rr:predicate ex:worksForDept;
            rr:objectMap [
            rr:parentTriplesMap ex:TriplesMap_Dept ;
            rr:joinCondition [ rr:child "DEPTNO"; rr:parent "DEPTNO" ]]].
            

             

            Do you think this problem related with mapping?

             

            Thanks,

            Pinar Gocebe

            • 3. Re: Cannot Create RDF View in R2RML Conversion Example
              alwu-Oracle

              Hi Pinar,

               

              I created the same staging table, loaded up exactly the same mapping file, run the create_rdfview_model, and

              could not reproduce the problem.

               

              Note that I created the "staging_table_name"  under schema SCOTT. And these are the commands I used.

               

              public class Test2616990

              {

                public static void main(String[] args) throws Exception

                {

                  String szJdbcURL = args[0];

                  String szUser    = args[1];

                  String szPasswd  = args[2];

               

                  String szModelName = args[3];

               

                  Oracle oracle = new Oracle(szJdbcURL, szUser, szPasswd);

                 

                  ModelOracleSem model = ModelOracleSem.createOracleSemModel(oracle, szModelName);

               

                  GraphOracleSem graph = model.getGraph();

               

                  FileInputStream is = new FileInputStream("map.rdf");

                  graph.getBulkUpdateHandler().prepareBulk(is,//inputstream 

                    "http://example.com", // base URI 

                    "N3", // data file type: can be RDF/XML, N-TRIPLE, etc. 

                    "SYSAUX", // tablespace 

                    null, // flags 

                    null, // listener 

                    "stage_table_name" // staging table name. 

                    ); 

                  model.close();   

                  oracle.dispose();

                }

              }

               

               

              alwu:lib/% cat run.sh

              java -classpath ./classes:jena-arq-2.9.2.jar:jena-core-2.7.2.jar:jena-iri-0.9.2.jar:log4j-1.2.16.jar:ojdbc6.jar:sdordfclient.jar:sdordf.jar:slf4j-api-1.6.4.jar:slf4j-simple-1.6.4.jar:xercesImpl-2.10.0.jar:xml-apis-1.4.01.jar Test2616990 jdbc:oracle:thin:@<host>:1521:rel12101  scott  <password>  zhe1

               

              BEGIN 

                  sem_apis.create_rdfview_model( 

                  model_name => 'rdf_view_name', 

                  tables => NULL, 

                  r2rml_table_owner => 'SCOTT', 

                  r2rml_table_name => 'STAGE_TABLE_NAME' 

                  ); 

                  END; 

              /

              SQL>   2    3    4    5    6    7    8    9 

               

               

              PL/SQL procedure successfully completed.

               

              Hope it helps,

               

              Zhe Wu

              • 4. Re: Cannot Create RDF View in R2RML Conversion Example
                Pinar Gocebe

                Hi Zhe,

                 

                Thanks for your help.

                Yes, I agree with you these steps seem to be true. I realize that our problem is related about client version of oracle distribution. Our oracle server version is 12.1 and client version is 11.6 ,So we upgrade client and problem has been solved.

                 

                I have another question. I can query this RDF view with SEM_MATCH function, but I want to query with SPARQL to use jena adapter. I try that ,but RDF view only holds metadata so I can only reach this metadata.

                Is it possible to querying virtual content of RDF View with SPARQL to use jena adapter?

                 

                Thanks,

                Pinar Gocebe

                • 5. Re: Cannot Create RDF View in R2RML Conversion Example
                  alwu-Oracle

                  Hi,

                   

                  Due to a server side bug, RDB2RDF does not work with the Jena APIs in 12.1.0.1. The problem has been fixed in 12.1.0.2.

                  For now, you can physically materialize the model and then query the content through Jena APIs.

                   

                  Hope it helps,

                   

                  Zhe Wu