Hi Martynas, I don't quite understand what this query is intended to achieve, but you could try wrapping the contents of the 2nd OPTIONAL into a sub-SELECT.
Richard > On 26 Oct 2019, at 20:43, Martynas Jusevičius <[email protected]> wrote: > > Hi, > > I have this simplified query > > PREFIX owl: <http://www.w3.org/2002/07/owl#> > > CONSTRUCT > { > ?s <smth> ?ab. > } > { > BIND (STRUUID() AS ?a) > ?s a owl:Class . > OPTIONAL { > ?s ?p ?o . > BIND (STRUUID() AS ?b) > } > OPTIONAL { > ?x ?y ?z . > BIND (STRUUID() AS ?c) > } > BIND (CONCAT(?a, "/", ?b) AS ?ab) > BIND (CONCAT(?a, "/", ?c) AS ?ac) > } > > What I'm getting is multiple ?ab UUIDs for the same ?s binding: > > skos:Collection <http://server/unset-base/smth> > > "520a2768-dd5e-4a5f-b2a8-09328ad89b3f/8d946969-92f2-4239-bad0-b0c92c606b9e" > , "520a2768-dd5e-4a5f-b2a8-09328ad89b3f/ce7863e0-33b6-47bf-bae3-e85b3e350636" > , "520a2768-dd5e-4a5f-b2a8-09328ad89b3f/b06ece07-cdbb-4196-ae34-f7676f739b55" > , "520a2768-dd5e-4a5f-b2a8-09328ad89b3f/2953ef49-775c-4f52-bdd0-f5b8f0cf82d6" > , "520a2768-dd5e-4a5f-b2a8-09328ad89b3f/0eb8c370-a672-4476-b1fe-f8e9acb93901" > , "520a2768-dd5e-4a5f-b2a8-09328ad89b3f/630bc8cb-30f0-4d87-93d1-0f24c432bc5f" > , "520a2768-dd5e-4a5f-b2a8-09328ad89b3f/f318a7f4-8510-4e42-ad60-18a711e6af0e" > , "520a2768-dd5e-4a5f-b2a8-09328ad89b3f/1d78b7ba-c8f7-42fb-8c72-a2f85732c8a0" > , "520a2768-dd5e-4a5f-b2a8-09328ad89b3f/5b606245-e5c1-4aa7-a98c-36bada0c21ef" > , "520a2768-dd5e-4a5f-b2a8-09328ad89b3f/01148de7-8ebb-4a6f-843f-8664a27e2eee" > . > > I would expect to get only one UUID per ?s. Can the query be > reformulated to achieve this? > I cannot move ?ab and ?ac inside the patterns next to STRUUID() > because ?a is undefined there. > > Doing SELECT (COUNT(DISTINCT ?ac) AS ?count) returns 11655 results > while it only returns 315 on Dydra. I think the difference is related > to this issue: > https://github.com/w3c/sparql-12/issues/102 > > I ran it on sparql.org over the skos.owl: > https://raw.githubusercontent.com/usc-isi-i2/karma-step-by-step/master/preloaded-ontologies/skos.owl > > Martynas
