Hello, sorry for asking again about a relevant question concerning GROUP_CONCAT but I think I found a problematic situation while I was running my queries. The previous question was this: http://answers.semanticweb.com/questions/20337/semantics-of-group_concat

I have a case in my queries where I want to combine GROUP_CONCAT with UNION and the VALUES clause.

AndyS suggested to use GROUP_CONCAT and UNION as following:

   { SELECT (GROUP_CONCAT(DISTINCT ?variable1; separator = ',') as ?var1) 
     { <http://dbpedia.org/resource/Peter> some_predicate_1 ?variable1 } }
   } UNION {
   { SELECT (GROUP_CONCAT(DISTINCT ?variable2; separator = ',') as ?var2)
     {?variable2 some_predicate_2 <http://dbpedia.org/resource/John> }

In this example, suppose we have for the ?variable1 and ?variable2 VALUES clauses bound to them with some values. Then something very strange happens.

I get for ?var1 and ?var2 all the values that both ?variable1 and ?variable2 contain. So both ?var1 and ?var2 are identical containing all the bindings for both variables!

I tested the query with FILTER (IN ()) and it work correctly. Also the results when I am not using GROUP_CONCAT and use UNION with VALUES are again correct.

Is this a Jena bug with GROUP_CONCAT and VALUES?

Thank you again for your help! Chris


{ SELECT (GROUP_CONCAT(DISTINCT ?variable1; separator = ',') as ?var1) 
    { VALUES ?variable1 { <http://dbpedia.org/resource/Peter> } ?variable1 some_predicate_1 ?object } 
{ SELECT (GROUP_CONCAT(DISTINCT ?variable2; separator = ',') as ?var2) 
    { VALUES ?variable2 { <http://dbpedia.org/resource/John> } ?subject some_predicate_2 ?variable2 } 

The result from Jena is: (?var1 = http://dbpedia.org/resource/Peter, http://dbpedia.org/resource/John" ) -> [Root]

and the same is the result for ?var2.

asked 13 Jan '13, 07:52

Christos's gravatar image

accept rate: 33%

edited 21 Jan '13, 18:34

Hard to tell without examples of the different things you have tried. It will depend on where in the query you put VALUES and FILTER(IN).

(14 Jan '13, 18:02) AndyS ♦ AndyS's gravatar image

I read about the ParameterizedSparqlString on the Jena website. If I do not find any solution for the above question, would you advise me to also check this solution?

In general, which is better in terms of performance? Submitting a concatenated String as query to Jena or using Jena's ParameterizedSparqlString to build the query? I know that the simply String solution has security issues and so on, but in this case I am only interested in terms of performance. Is there any other approach?

Thanks again!

(21 Jan '13, 18:56) Christos Christos's gravatar image
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 13 Jan '13, 07:52

question was seen: 1,424 times

last updated: 21 Jan '13, 18:58