Strange results from Sparql Queries.

21 views
Skip to first unread message

Phil Ashworth

unread,
Feb 22, 2017, 2:51:11 PM2/22/17
to Information Workbench Discussions
I have IWB connected to a Virtuoso database via the sparql endpoint.
I am creating some templates to display the data but getting odd results form the sparql queries.

I'm using as failrly simple query in the template
select distinct  ?Year ?Month ?dataset
WHERE {
       ?yearslice qb:sliceKey pvcubemodel:sliceByYear .
       ?monthslice qb:sliceKey pvcubemodel:sliceByMonth .
        ?observation qb:dataSet ?dataset .
?yearslice  qb:observation ?observation .
        ?monthslice  qb:observation ?observation .
?yearslice qb:order ?Year .
        ?monthslice qb:order ?Month .
        ?ObsClass rdfs:subClassOf* qb:Observation .
?observation a ?ObsClass .
filter (?Year = {{{year}}} ) .
} order by ?Month

However the template page does seem to show the correct amount of data.
I see the same behavior in the IWB sparql page.

Lets use the following query

select distinct  ?Year ?Month ?dataset
WHERE {
       ?yearslice qb:sliceKey pvcubemodel:sliceByYear .
       ?monthslice qb:sliceKey pvcubemodel:sliceByMonth .
        ?observation qb:dataSet ?dataset .
?yearslice  qb:observation ?observation .
        ?monthslice  qb:observation ?observation .
?yearslice qb:order ?Year .
        ?monthslice qb:order ?Month .
        ?ObsClass rdfs:subClassOf* qb:Observation .
?observation a ?ObsClass .
filter (?Year = 2011) .
} order by ?Month

This returns 8 rows in IWB ... ! Yet the same query asked directly in Virtuoso gives the correct 12 rows of data

Change 2011 to 2013 and I get no data returned but still the correct 12 rows directly in Virtuoso.
Change it 2015 and I get 2 rows in IWB ... Yep 12 from Virtuoso directly.

I have changed the query order around and this does effect things so I may get 12 rows for 2011 but only 6 for 2015.
What is even more bizzare is that the template displays a list, table, barchart and piechart of the data all using the same query.
However the list may have 8 items in it, whilst the table 2 items, the barchart has 12 and the pie chart 6 items.

Any idea what is going on ?







Andreas Schwarte

unread,
Feb 23, 2017, 2:49:26 AM2/23/17
to iwb-dis...@googlegroups.com

Hello Phil,

 

This sounds sounds really strange. In our tests we can successfully connect to a virtuoso triple store and retrieve correct results.

 

A few questions / ideas:

 

  1. Are you maybe using “inference” when evaluating the query via the Virtuoso instance directly? In information Workbench we send the queries with ‘infer=false’ by default, can be activated on the query level though (e.g. on the SPARQL endpoint)
  2. Are the namespaces for qb and pvcubemodel correctly defined
  3. Do you maybe have differences in the year literal, e.g. “2012” vs “2012”^^xsd:string (which makes a difference in queries)
  4. Can you try to leave out the filter for the year and check the result

 

Also: how are you connecting to the virtuoso instance? The best practice is to use the virtuoso-bridge extension (i.e. a Virtuoso Sesame connector) which you can find as an app in our app center [1].

 

Hope this helps,

Andreas

 

[1] https://appcenter.fluidops.com/

--
You received this message because you are subscribed to the Google Groups "Information Workbench Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iwb-discussio...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Phil Ashworth

unread,
Feb 23, 2017, 3:57:25 AM2/23/17
to Information Workbench Discussions

Hi Andreas

I hope you are well.
In answer to your questions...
  1. Are you maybe using “inference” when evaluating the query via the Virtuoso instance directly? In information Workbench we send the queries with ‘infer=false’ by default, can be activated on the query level though (e.g. on the SPARQL endpoint)
  2. Are the namespaces for qb and pvcubemodel correctly defined
  3. Do you maybe have differences in the year literal, e.g. “2012” vs “2012”^^xsd:string (which makes a difference in queries)
  4. Can you try to leave out the filter for the year and check the result
1. No... there is no inference being used. All the data exists and is physically in the store.
2. Yes they are... otherwise it won't work at all, rather than give some results
3. No.... they are all Integers
4. That was an interesting question and I didn't get the result I was expecting.... in theory it should have given 74 rows but it still just gave the 8 rows for 2011.... That's weird
I invalidated caches etc and still got the same result. I also checked the same query directly in Virtuoso and indeed I got the 74 rows

>Also: how are you connecting to the virtuoso instance? 
I'm currently connecting as a sparql repository I'll get the connector downloaded and installed and give it a go.
Thanks
PS some images to show 









 









Phil Ashworth

unread,
Feb 23, 2017, 4:08:50 AM2/23/17
to Information Workbench Discussions

Hi Andreas
Virtuoso Connector installed and all is now working correctly which is great.
But it still raises the question that there does seem to be an issue somewhere when the two are connected as a sparql repo.

Cheers
Phil

Andreas Schwarte

unread,
Feb 23, 2017, 10:08:12 AM2/23/17
to iwb-dis...@googlegroups.com

Hi Phil,

 

not sure how it can happen that the SPARQL Repository behaves differently – we didn’t observe this in our tests, but will have an eye on this.

 

In any case: it is best practice to use the virtuoso connector (which also optimizes the connections internally). We are glad to hear that this is working fine for you.

 

Best,

Andreas

 

 

Von: iwb-dis...@googlegroups.com [mailto:iwb-dis...@googlegroups.com] Im Auftrag von Phil Ashworth


Gesendet: Donnerstag, 23. Februar 2017 10:09
An: Information Workbench Discussions <iwb-dis...@googlegroups.com>

--

Reply all
Reply to author
Forward
0 new messages