[
https://issues.apache.org/jira/browse/JENA-2340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17567454#comment-17567454
]
Andy Seaborne commented on JENA-2340:
-------------------------------------
A "solution mapping" is a row during the query evaluation. The mapping is from
variables in the row to the values of those variables.
{{?s ?p ?o}} matches
{noformat}
:s1 :q "one" .
:s1 :p "one" .
{noformat}
with two rows, two solution mappings.
There is going to have to something to connect the same values of {{{}?o{}}}.
One way to do it is build an intermediate table with the mapping you want and
join this to the {{{}?s ?p ?o{}}}.
{noformat}
SELECT ?s ?p ?o ?o_node
WHERE{
{ SELECT ?o ?o_node {
{ SELECT DISTINCT ?o { ?s ?p ?o } }
BIND(BNODE(?o) AS ?o_node)
}
}
?s ?p ?o
}
{noformat}
which gives:
{noformat}
-----------------------------
| s | p | o | o_node |
=============================
| :s0 | :p | "one" | _:b0 |
| :s1 | :p | "one" | _:b0 |
| :s1 | :q | "one" | _:b0 |
| :s3 | :p | "two" | _:b1 |
| :s2 | :p | "two" | _:b1 |
-----------------------------
{noformat}
> bnode() with literal argument
> -----------------------------
>
> Key: JENA-2340
> URL: https://issues.apache.org/jira/browse/JENA-2340
> Project: Apache Jena
> Issue Type: Bug
> Affects Versions: Jena 4.5.0
> Reporter: Justin
> Priority: Major
> Attachments: a2.rq, a2.ttl
>
>
> [^a2.rq]
>
> About the bnode() function:
> "If the form with a simple literal is used, every call results in distinct
> blank nodes for different simple literals, and the same blank node for calls
> with the same simple literal within expressions for one [solution
> mapping|https://www.w3.org/TR/sparql11-query/#defn_sparqlSolutionMapping]."
> [https://www.w3.org/TR/sparql11-query/]
>
> In the following example I expected the same bnode to appear multiple times
> in the o_node column. But instead Jena doesn't reuse any of the bnodes.
> {code:java}
> root@354840b30d6f:/mnt# cat ./a2.ttl
> @prefix : <http://example/>
> :s0 :p "one" .
> :s1 :q "one" .
> :s1 :p "one" .
> :s2 :p "two" .
> :s3 :p "two" .
> root@354840b30d6f:/mnt# cat ./a2.rq
> prefix : <http://example/>
> select *
> where{
> ?s ?p ?o
> bind(bnode(?o) as ?o_node)
> }
> root@354840b30d6f:/mnt# ./apache-jena-4.5.0/bin/sparql --data=./a2.ttl
> --query=./a2.rq
> -----------------------------
> | s | p | o | o_node |
> =============================
> | :s0 | :p | "one" | _:b0 |
> | :s3 | :p | "two" | _:b1 |
> | :s2 | :p | "two" | _:b2 |
> | :s1 | :p | "one" | _:b3 |
> | :s1 | :q | "one" | _:b4 |
> ----------------------------- {code}
> How do you get the bnode() function with a literal argument to return the
> same bnode?
> I feel like perhaps I am not understanding what it means to have "one
> solution mapping."
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]