You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jena.apache.org by GitBox <gi...@apache.org> on 2022/04/25 15:21:02 UTC

[GitHub] [jena] Aklakan opened a new issue, #1272: The IRI function in UpdateRequests ignores BASE IRIs

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

   The following query works as expected:
   ```
   BASE <https://foo.bar/> SELECT ?x { BIND(IRI('baz') AS ?x) }"
   ```
   
   ```
   -------------------------
   | x                     |
   =========================
   | <https://foo.bar/baz> |
   -------------------------
   ```
   
   However, using the same graph pattern in the following update request ...
   ```
   BASE <https://foo.bar/> INSERT { ?x ?x ?x } WHERE { BIND(IRI('baz') AS ?x) }
   CONSTRUCT WHERE { ?s ?p ?o }
   ```
   
   ... yields a result that suggests that the the base IRI was ignored:
   ```
   <file:///tmp/baz>  <file:///tmp/baz>  <file:///tmp/baz> .
   ```
   
   The [sparql update spec](https://www.w3.org/TR/sparql11-update/) does not say anything about the IRI function so my assumption is that the behavior should be consistent with that for querying. As a consequence, the issue is with the behavior of Jena.
   
   The reason is that the `E_IRI` function is only implemented to extract the base IRI from a currently running query - it lacks the logic to work with update requests.
   
   ```
   class E_IRI {
       @Override
       public NodeValue eval(NodeValue v, FunctionEnv env)
       { 
           String baseIRI = null ;
           if ( env.getContext() != null )
           {
               Query query = (Query)env.getContext().get(ARQConstants.sysCurrentQuery) ;
               if ( query != null )
                   baseIRI = query.getBaseURI() ;
           }
           return NodeFunctions.iri(v, baseIRI) ;
       }
   }
   ```
   
   UpdateRequest and Query both implement Prologue - so maybe `ARQConstants.sysCurrentQuery` could be changed to ARQConstants.sysCurrent*Prologue*?


-- 
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: issues-unsubscribe@jena.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] afs commented on issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
afs commented on issue #1272:
URL: https://github.com/apache/jena/issues/1272#issuecomment-1108833155

   `ARQConstants.sysCurrentPrologue` would seem the better fix.
   
   Noticed:
   `QueryExecDataset` and `QueryExecDatasetBuilder` both set `ARQConstants.sysCurrentQuery` which isn't right.


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] afs commented on issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
afs commented on issue #1272:
URL: https://github.com/apache/jena/issues/1272#issuecomment-1144053575

   Closed by PR #1343.


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] afs commented on issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
afs commented on issue #1272:
URL: https://github.com/apache/jena/issues/1272#issuecomment-1143631502

   Let's do one thing at a time.
   


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] afs commented on issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
afs commented on issue #1272:
URL: https://github.com/apache/jena/issues/1272#issuecomment-1137758183

   There isn't anything special about update: the prologue accumulates. For BASE that is "replace" although the new base URI is resolved against the previous one, starting from the file or URL the query is read from.
   
   ```
   BASE <http://base/>
   PREFIX ex: <z1/z2/>
   BASE <y/>
   PREFIX : <a>
   
   SELECT (:123 AS ?X) (ex:456 AS ?Y)
   WHERE {}
   ```
   gives `http://base/y/a123` ,`http://base/z1/z2/456`.
   ```
   
   Repeated prologues in update are just updating the active prefixes and base as the parser goes along.
   


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] afs commented on issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
afs commented on issue #1272:
URL: https://github.com/apache/jena/issues/1272#issuecomment-1140230093

   #1343 does static scoping.
   
   It makes these 
   ```
   BIND(<x> as ?X1)
   BIND(IRI("<x>") as ?X2)
   ```
   in an update both produce the same IRI.
   


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] afs closed issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
afs closed issue #1272: The IRI function in UpdateRequests ignores BASE IRIs
URL: https://github.com/apache/jena/issues/1272


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] afs commented on issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
afs commented on issue #1272:
URL: https://github.com/apache/jena/issues/1272#issuecomment-1142552968

   PR #1343 provides static scoping and includes an extension which is "IRI" with a provided base `IRI(base, rel)`.
   
   There are now 2 IRI "E_" functions: the standard "E_IRI" takes on argument and records the pasrer base and "E_IRI2" which has two arguments - (base, rel) - and because base can be relative, it also records the parser base.
   
   These become functions (iri) and (iri2) in the algebra.


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] Aklakan commented on issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
Aklakan commented on issue #1272:
URL: https://github.com/apache/jena/issues/1272#issuecomment-1143513890

   Seems very reasonable to me.
   
   Though - while we are at it - I wouldn't be opposed to an IRI function that can yield relative IRIs "as given" - e.g. not resolving ../../foo.bar against the base.
   It's somehow odd that one can put a turtle file on the Web with relative IRIs pointing e.g. to resources such as downloads or ontology files - but there is no way to create such relative IRIs with SPARQL.
   So maybe E_IRI2 could have an optional third boolean parameter whether to resolve against the parser base if the given base is relative which defaults to true.
   


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] Aklakan commented on issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
Aklakan commented on issue #1272:
URL: https://github.com/apache/jena/issues/1272#issuecomment-1137710213

   There is now a best-effort PR - however I am not sure about the SPARQL spec and whether this actually opens a pandora's box:
   
   The sparql spec's [grammar](https://www.w3.org/TR/sparql11-query/#sparqlGrammar) allows for multiple prologues on each `Update` - and I am not sure whether actually need to stay separate or whether only the last one takes precedence.
   
   ```
   [29] | Update | ::= | Prologue ( Update1 ( ';' Update )? )?
   ```
   
   In any case, with Jena I get:
   ```java
   UpdateRequest req = UpdateFactory.create(String.join(";\n",
     "BASE <http://foo.foo/> INSERT { ?s ?s ?s } WHERE { BIND(IRI('s') AS ?s) }",
     "BASE <http://bar.bar/> INSERT { ?x ?x ?x } WHERE { BIND(IRI('x') AS ?x) }"));
   System.out.println(req);
   ```
   
   ```
   BASE    <http://bar.bar/>
   
   INSERT {
     ?s ?s ?s .
   }
   WHERE
     { BIND(iri("s") AS ?s) } ;
   INSERT {
     ?x ?x ?x .
   }
   WHERE
     { BIND(iri("x") AS ?x) }
   ```
   
   Not sure if this is the correct semantics or whether jena's update model actually deviates from the spec here.
   
   
   


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] Aklakan commented on issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
Aklakan commented on issue #1272:
URL: https://github.com/apache/jena/issues/1272#issuecomment-1137785955

   Ok, so that means that the IRI function then only sees the final accumulated base IRI (and not that of the respective Update operation)


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] afs commented on issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
afs commented on issue #1272:
URL: https://github.com/apache/jena/issues/1272#issuecomment-1137814567

   This is a dynamic vs static scoping issue.
   
   Whole update is dynamic, picking base up at runtime. Same base through out the update (i.e. last).
   
   The static style alternative is the syntax element for the IRI function could record the base at point of creation i.e. the IRI function captures the parser base, and not have context at execution time.
   
   I don't recall when I last saw a real-world update with split prologue.
   


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] afs commented on issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
afs commented on issue #1272:
URL: https://github.com/apache/jena/issues/1272#issuecomment-1137846903

   "static" is a parser change - I'll try it out.
   
   (The fact Query and UpdateRequest extend Prologue was a mistake but we are where we are.)


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


[GitHub] [jena] Aklakan commented on issue #1272: The IRI function in UpdateRequests ignores BASE IRIs

Posted by GitBox <gi...@apache.org>.
Aklakan commented on issue #1272:
URL: https://github.com/apache/jena/issues/1272#issuecomment-1137834831

   > Making it whole update is dynamic, picking base up at runtime; that becomes "last BASE" through out the update.
   
   This is at least the easiest thing to implement for the time being - although the statically scoped interpretation is clearly the intuitive one. But the latter would require quite some refactoring.
   
   > I don't recall when I last saw a real-world update with split prologue.
   Yes, the cheap solution would be to drop split prologues from the spec 😁 
   


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org