tkaryadis opened a new issue, #1874:
URL: https://github.com/apache/jena/issues/1874

   ### Version
   
   4.8.0
   
   ### What happened?
   
   I wanted to write this simple RDF-star query using the Jena query builder : 
   
   ```sparql
   SELECT  ?city
   WHERE
     { << <https://squery.org/joy/athens> <https://squery.org/joy/connected> 
?city >>
                 <https://squery.org/joy/distance>  
"500"^^<http://www.w3.org/2001/XMLSchema#int>}
   ```
   
   My code :
   ```java
   var athens = ResourceFactory.createResource( 
"https://squery.org/joy/athens";).asNode();
   var connected =ResourceFactory.createProperty( 
"https://squery.org/joy/connected";).asNode();
   var city_var  = Var.alloc("city").asNode();
   
   Node_Triple node_triple = new Node_Triple(athens,connected,city_var);
   
   var distance = ResourceFactory.createResource(  
"https://squery.org/joy/distance";).asNode();
   var l500 = ResourceFactory.createTypedLiteral( 500).asNode();
   
    Triple triple = Triple.create(node_triple,distance,l500);
   
     SelectBuilder s = new SelectBuilder();
           var q=
           s.addVar("?city")        
           .addWhere(triple)
           .build()
           .toString();
       
      System.out.println(q);
   ```
   
   Exception : 
   ```java
   Exception in thread "main" java.lang.IllegalArgumentException: Subject (<< 
https://squery.org/joy/athens @https://squery.org/joy/connected ?city >>) must 
be a URI, blank, variable, or a wildcard. 
   Is a prefix missing?  Prefix must be defined before use. 
   
           at 
org.apache.jena.arq.querybuilder.handlers.WhereHandler.testTriple(WhereHandler.java:200)
           at 
org.apache.jena.arq.querybuilder.handlers.WhereHandler.addWhere(WhereHandler.java:212)
           at 
org.apache.jena.arq.querybuilder.SelectBuilder.addWhere(SelectBuilder.java:307)
           at org.apache.jena.arq.querybuilder.MyMain.main(MyMain.java:44)
   ```        
   I used the source code and i comment the error checking on 
querybuilder/handlers/wherehandler,
   private static void testTriple(TriplePath t)    function and it worked, 
maybe the wherehanlder is not updated for RDF-star,
   and throws exception. After making comment the //throw new 
IllegalArgumentException(sb.toString());
   
   I got the expected output : 
   
   ```sparql
   SELECT  ?city
   WHERE
     { << <https://squery.org/joy/athens> <https://squery.org/joy/connected> 
?city >>
                 <https://squery.org/joy/distance>  
"500"^^<http://www.w3.org/2001/XMLSchema#int>}
   ```        
   
   
   
   ### Relevant output and stacktrace
   
   _No response_
   
   ### Are you interested in making a pull request?
   
   None


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to