You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jena.apache.org by "HolgerKnublauch (via GitHub)" <gi...@apache.org> on 2026/08/05 01:28:56 UTC

[I] SPARQL CONSTRUCT: Missing rdf:reifies triple when pre-bound variable is in the reified triple [jena]

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

   ### Version
   
   6.2.0
   
   ### What happened?
   
   There appears to be a problem with the RDF 1.2 annotation syntax in CONSTRUCT queries when one of the variables is pre-bound. The rdf:reifies triple is missing from the output. It works fine for variables that are bound during the WHERE clause.
   
   ```
   import java.util.Map;
   
   import org.apache.jena.query.Query;
   import org.apache.jena.query.QueryExecution;
   import org.apache.jena.query.QueryExecutionFactory;
   import org.apache.jena.query.QueryFactory;
   import org.apache.jena.query.Syntax;
   import org.apache.jena.rdf.model.Model;
   import org.apache.jena.rdf.model.ModelFactory;
   import org.apache.jena.rdf.model.ResourceFactory;
   import org.apache.jena.riot.Lang;
   import org.apache.jena.riot.RDFDataMgr;
   import org.apache.jena.sparql.core.Var;
   import org.apache.jena.sparql.syntax.syntaxtransform.QueryTransformOps;
   import org.apache.jena.vocabulary.OWL;
   
   /**
    * Standalone demo: runs a CONSTRUCT query with an RDF-star annotation
    * ({| ... |}) with $this substituted for owl:Thing before execution.
    */
   public class RDFStarConstructDemo {
   
   	public static void main(String[] args) {
   		String queryString =
   				"PREFIX ex: <http://example.com/>\n" +
   				"CONSTRUCT {\n" +
   				"	$this ex:seeAlso ex:Nothing {| ex:tempTriple true |} .\n" +
   				"}\n" +
   				"WHERE {\n" +
   				"}\n";
   
   		Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
   
   		query = QueryTransformOps.replaceVars(query, Map.of(
   				Var.alloc("this"), ResourceFactory.createResource(OWL.Thing.getURI()).asNode()));
   
   		Model model = ModelFactory.createDefaultModel();
   
   		try (QueryExecution qexec = QueryExecutionFactory.create(query, model)) {
   			Model result = qexec.execConstruct();
   			RDFDataMgr.write(System.out, result, Lang.TURTLE);
   		}
   	}
   }
   ```
   
   ### Relevant output and stacktrace
   
   ```shell
   PREFIX ex: <http://example.com/>
   
   [ ex:tempTriple  true ] .
   
   <http://www.w3.org/2002/07/owl#Thing>
           ex:seeAlso  ex:Nothing .
   ```
   
   ### 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: 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


Re: [I] SPARQL CONSTRUCT: Missing rdf:reifies triple when pre-bound variable is in the reified triple [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on issue #4129:
URL: https://github.com/apache/jena/issues/4129#issuecomment-5203571348

   @adityaanikam The problem is in `QueryTransformOps`.


-- 
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


Re: [I] SPARQL CONSTRUCT: Missing rdf:reifies triple when pre-bound variable is in the reified triple [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs closed issue #4129: SPARQL CONSTRUCT: Missing rdf:reifies triple when pre-bound variable is in the reified triple
URL: https://github.com/apache/jena/issues/4129


-- 
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


Re: [I] SPARQL CONSTRUCT: Missing rdf:reifies triple when pre-bound variable is in the reified triple [jena]

Posted by "adityaanikam (via GitHub)" <gi...@apache.org>.
adityaanikam commented on issue #4129:
URL: https://github.com/apache/jena/issues/4129#issuecomment-5190310682

   Looked into this before committing to a root cause. Confirmed the general area, CONSTRUCT template instantiation and reification triple emission span `Template.java` in `jena-arq` along with the RDF 1.2 reification vocabulary handling introduced for `rdf:reifies`, but pinning the exact branch that drops the reifies triple when a variable inside the reified triple is pre-bound needs more tracing than I have done yet, since template substitution and reification emission appear to be handled in separate passes rather than one obvious function.
   
   I would like to work on this. Plan is to build the small reproduction query from your report, step through template instantiation with a debugger to see exactly where the reifies triple is decided, and confirm whether the drop happens during variable substitution itself or during the separate reification bookkeeping step. Will report back with the actual line once I have traced it, rather than guess given how easy it is to get RDF 1.2 reification semantics subtly wrong.


-- 
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