2 Replies Latest reply on Nov 4, 2009 6:36 PM by alwu-Oracle

    "_" character + optional clause in SPARQL gives SQL error

    671085
      Hello

      I run the following query through Jena Adaptor (11.1.0.7) (note the "_(E00-E90)" part of the URI) :

      PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
      PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      SELECT DISTINCT ?predicate ?object ?objectLabel
      WHERE {
      <http://www.chu-rouen.fr/stms#CIM10_(E00-E90)> ?predicate ?object .
      OPTIONAL {?object rdfs:label ?objectLabel.}
      }
      LIMIT 5

      I have the following exception in the Jena adaptor (note the corresponding "(E00-E90)" in the last SQL query) :

      15:07:15,191 INFO [OracleSPARQLDOMEndPoint] Query: PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf:
      <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT DISTINCT ?predicate ?object ?objectLabel WHERE { <http://w
      ww.chu-rouen.fr/stms#CIM10_(E00-E90)> ?predicate ?object . OPTIONAL { ?object  rdfs:label  ?
      objectLabel .} } LIMIT 5
      15:07:15,191 INFO [OracleSemQueryPlan] Final clause = SELECT object$RDFVTYP, object$RDFLTYP, object$RDFLANG, object$RDF
      CLOB, decode(object$RDFVTYP, 'BLN', ('_:'||substr(object,instr(object,'m',4)+1)), object) object, predicate$RDFVTYP, de
      code(predicate$RDFVTYP, 'BLN', ('_:'||substr(predicate,instr(predicate,'m',4)+1)), predicate) predicate FROM table(sdo_
      rdf_match('(<http://www.chu-rouen.fr/stms#CIM10_(E00-E90)> ?predicate ?object) ', sdo_rdf_models('RDF_MODEL'), sdo_rdf_r
      ulebases('OWLPRIME'), null, null, null))
      15:07:15,191 INFO [OracleSemQueryPlan] Final clause = SELECT objectLabel$RDFVTYP, objectLabel$RDFLTYP, objectLabel$RDFL
      ANG, objectLabel$RDFCLOB, decode(objectLabel$RDFVTYP, 'BLN', ('_:'||substr(objectLabel,instr(objectLabel,'m',4)+1)), obj
      ectLabel) objectLabel FROM table(sdo_rdf_match('(<http://www.chu-rouen.fr/stms#CIM10Chapitre> <http://www.w3.org/2000/0
      1/rdf-schema#label> ?objectLabel) ', sdo_rdf_models('RDF_MODEL'), sdo_rdf_rulebases('OWLPRIME'), null, null, null))
      15:07:15,207 INFO [OracleSemQueryPlan] Final clause = SELECT objectLabel$RDFVTYP, objectLabel$RDFLTYP, objectLabel$RDFL
      ANG, objectLabel$RDFCLOB, decode(objectLabel$RDFVTYP, 'BLN', ('_:'||substr(objectLabel,instr(objectLabel,'m',4)+1)), obj
      ectLabel) objectLabel FROM table(sdo_rdf_match('("(E00-E90)" <http://www.w3.org/2000/01/rdf-schema#label> ?objectLabel)
      ', sdo_rdf_models('RDF_MODEL'), sdo_rdf_rulebases('OWLPRIME'), null, null, null))
      15:07:15,254 WARN [QueryIteratorCheck] Open iterator: QueryIterBlockTriplesQH$StagePattern/322
      15:07:15,254 ERROR [STDERR] oracle.spatial.rdf.client.jena.NoEntailmentException: executeBindings: ORA-29532: appel Java
      arrÛtÚ par une exception Java non interceptÚe : oracle.spatial.rdf.server.ParseException: Encountered "\"(E00-E90)\"" a
      t line 1, column 2.
      Was expecting one of:
      <URI> ...
      <QNAME> ...
      <VAR> ...

      ORA-06512: Ó "MDSYS.RDF_MATCH_IMPL_T", ligne 181
      ORA-06512: Ó "MDSYS.RDF_MATCH_IMPL_T", ligne 67
      ORA-06512: Ó ligne 4
      15:07:15,254 ERROR [STDERR] at oracle.spatial.rdf.client.jena.OracleSemQueryPlan.executeBindings(OracleSemQueryPlan.java:334)
      15:07:15,254 ERROR [STDERR] at com.hp.hpl.jena.sparql.engine.iterator.QueryIterBlockTriplesQH$StagePattern.<init>(QueryIterBlockTriplesQH.java:89)
      15:07:15,254 ERROR [STDERR] at com.hp.hpl.jena.sparql.engine.iterator.QueryIterBlockTriplesQH.nextStage(QueryIterBlockTriplesQH.java:55)
      15:07:15,254 ERROR [STDERR] at com.hp.hpl.jena.sparql.engine.iterator.QueryIterRepeatApply.makeNextStage(QueryIterRepeatApply.java:92)
      15:07:15,254 ERROR [STDERR] at com.hp.hpl.jena.sparql.engine.iterator.QueryIterRepeatApply.hasNextBinding(QueryIterRepeatApply.java:54)
      etc.

      However :

      If I remove the OPTIONAL clause, the error disapear.
      If I simply remove the "_" character from the URI, the error disappear.
      If I do a query where the URI is in the "object" part of the triple, the error disappear. ie :

      PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
      PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      SELECT DISTINCT ?predicate ?subject ?subjectLabel
      WHERE {
      ?subject ?predicate <http://www.chu-rouen.fr/stms#CIM10_(E00-E90)> .
      OPTIONAL {?subject rdfs:label ?subjectLabel.}
      }


      Is that a bug ?
      Thanks
      Thomas

      Edited by: thomas francart on 4 nov. 2009 15:14
        • 1. Re: "_" character + optional clause in SPARQL gives SQL error
          alwu-Oracle
          Hi,

          I assume you are using Jena Adaptor v2. It is a v2 bug. This problem does not have much to do with "_" actually. Rather, it is because ARQ is breaking this query into a nested loop and ?object is bound to a literal and that literal is in turn passed to the OPTIONAL part as a binding. SEM_MATCH complains because it receives a literal subject which is illegal.

          The latest Jena Adaptor should be free of this problem. And it is a lot faster dealing with OPTIONALs, UNIONs, Filters in general.
          Please check
          http://www.oracle.com/technology/software/tech/semantic_technologies/index.html

          If you want to continue using Jena Adaptor v2, can you please try the following workaround? A FILTER is added to the OPTIONAL clause.

          PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
          PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
          SELECT DISTINCT ?predicate ?object ?objectLabel
          WHERE {
          <http://www.chu-rouen.fr/stms#CIM10_(E00-E90)> ?predicate ?object .
          OPTIONAL {?object rdfs:label ?objectLabel  *FILTER isURI(?object)*}
          }
          LIMIT 5

          Thanks,

          Zhe Wu
          • 2. Re: "_" character + optional clause in SPARQL gives SQL error
            alwu-Oracle
            NOTE: I don't know what is going on with this Forum posting. I marked "FILTER isURI(?object)" using bold font. Somehow, * is shown :( Please get rid of the * from the above query.

            Thanks,

            Zhe