YvanDesPatates opened a new issue, #3707: URL: https://github.com/apache/jena/issues/3707
### Version 5.6.0 ### What happened? Jena do not handle adding a clause values in a where clause nor in an optional clause. Here is a minimal exemple (I also give a .zip minimal maven project with .jar in it maybe it's more convenient.). [jena-test.zip](https://github.com/user-attachments/files/24734796/jena-test.zip) ```java public static void main( String[] args ) { Var uriVar = Converters.makeVar("uri"); Var siteAdressVar = Converters.makeVar("siteAddress"); Var cityVar = Converters.makeVar("city"); SelectBuilder select = new SelectBuilder(); select.addVar(uriVar); SelectBuilder selectOptional = new SelectBuilder(); selectOptional.addVar(uriVar) .addVar(cityVar); selectOptional.addWhere(uriVar, ORG.siteAddress, siteAdressVar); selectOptional.addWhere(siteAdressVar, VCARD4.locality.asNode(), cityVar); System.out.println("[ optional select clause ]"); System.out.println(selectOptional); System.out.println("----------------------------------------"); select.addOptional(selectOptional); System.out.println("[ final select query ]"); System.out.println(select.build()); System.out.println("----------------------------------------"); } ``` --- output : ``` [ optional select clause ] SELECT ?uri ?city WHERE { ?uri <http://www.w3.org/ns/org#siteAddress> ?siteAddress . ?siteAddress <http://www.w3.org/2006/vcard/ns#locality> ?city} ---------------------------------------- [ final select query ] SELECT ?uri WHERE { OPTIONAL { ?uri <http://www.w3.org/ns/org#siteAddress> ?siteAddress . ?siteAddress <http://www.w3.org/2006/vcard/ns#locality> ?city}} ---------------------------------------- ``` The original purpose was to sort on the `?city` var which is not returned. For information here is the original request i want to create (tested and validated on an RDF4J workbench server). <details> <summary>full request here</summary> ``` PREFIX org: <http://www.w3.org/ns/org#> PREFIX dc: <http://purl.org/dc/terms/> PREFIX os-sec: <http://www.opensilex.org/security#> PREFIX vcard: <http://www.w3.org/2006/vcard/ns#> SELECT DISTINCT ?uri ?rdfType ?rdfTypeName ?lastUpdateDate ?name ?description ?publisher ?publicationDate ?address ?locationObservationCollection WHERE { ?rdfType (rdfs:subClassOf)* org:Site OPTIONAL { ?rdfType rdfs:label ?rdfTypeName FILTER langMatches(lang(?rdfTypeName), "en") } OPTIONAL { ?rdfType rdfs:label ?rdfTypeName FILTER langMatches(lang(?rdfTypeName), "") } GRAPH <http://phenome.inrae.fr/m3p/set/organization> { ?uri rdf:type ?rdfType OPTIONAL { ?uri dc:modified ?lastUpdateDate} OPTIONAL { ?uri rdfs:label ?name} OPTIONAL { ?uri rdfs:comment ?description} OPTIONAL { ?uri dc:publisher ?publisher} OPTIONAL { ?uri dc:issued ?publicationDate} OPTIONAL { ?uri org:siteAddress ?address} } OPTIONAL { GRAPH <http://phenome.inrae.fr/m3p/set/ObservationCollection> { OPTIONAL { ?locationObservationCollection <http://www.w3.org/ns/sosa/hasFeatureOfInterest> ?uri}}} OPTIONAL { ?_organization org:hasSite ?uri} OPTIONAL { ?uri os-sec:hasGroup ?groups . ?groups os-sec:hasUserProfile ?userProfiles . ?userProfiles os-sec:hasUser <http://phenome.inrae.fr/m3p/id/user/account.guestopensilexorg>} OPTIONAL { { SELECT ?uri ?city WHERE { ?uri org:siteAddress ?address . ?address vcard:locality ?city . } } } FILTER ( ! isBlank(?uri) ) } ORDER BY DESC(?city) ASC(?uri) LIMIT 100 ``` </details> ### Relevant output and stacktrace ```shell ``` ### 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]
