I have set up stardog on my machine and followed the music vkg tutorial and wanted to see how I could query this VKG using the BI Server function. As you can see, I am able to query the data that is in a MySQL server in Azure:
But when I access the BI Server I am not getting any songs. Please see the below (query the SPARQL from above to show data, switch to the biserver and table is empty)
bash-4.2$ /opt/stardog/bin/stardog query execute music /var/opt/stardog/tutorial-content/demo-vkg/music_query_2.sparql
+--------+--------------+
| song | name |
+--------+--------------+
| :Song1 | "Love Me Do" |
+--------+--------------+
Query returned 1 results in 00:00:01.656
bash-4.2$ exit
*[master][~/Projects/stardog]$
*[master][~/Projects/stardog]$ mysql -h 127.0.0.1 -P5806 -u admin -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 80
Server version: 5.7.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use music;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+-----------------+
| Tables_in_music |
+-----------------+
| Artist |
| Song |
| Songwriter |
+-----------------+
3 rows in set (0.06 sec)
mysql> select * from Song;
Empty set (0.08 sec)
mysql>
Thanks for following up. I was on vacation for a few days.
A few things to check:
Your BI mappings use the default namespace (eg. :Song). This must be consistent with that in the SPARQL query.
In your SPARQL query, you ask for the :name predicate values, but in the BI mapping, you used :length. Is :length present in your data? For the sake of ttroubleshooting, please remove/comment the "writer" mapping until you can get a minimal version working with either :name or :length.
bash-4.2$ ${STARDOG_PATH}/stardog query execute music ${tutorial_content}/music_query_2.sparql
+--------+--------------+--------+
| song | name | length |
+--------+--------------+--------+
| :Song1 | "Love Me Do" | 125 |
+--------+--------------+--------+
The create statement looks fine in the BI Server:
mysql> show create table Song;
+-------+------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+------------------------------------------------------------------------------------------------------------------------------------+
| Song | CREATE TABLE `music`.`Song` (
`id` varchar(512) NOT NULL,
`length` bigint(21) NOT NULL,
`Song Title` varchar(512) NOT NULL
) |
+-------+------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.07 sec)
Note: I'm not sure if this will make a difference, but my .ttl doesn't have an id field described (Though I assume it will take this from the SongID seemingly generated by Stardog in SPARQL (i.e. Song1 from the results above)
Hopefully this helps, let me know if there is anything more I should provide!
I think this is the issue. The default prefix is different in your SPARQL query. Can you try removing this and then clearing+reloading the named graph containing the BI/SQL mappings?
I just realized you're querying a virtual graph here. For that to work with a BI query, you'll need to enable the Virtual Transparency setting on your database. Without this, the BI query will only cover local data. We'll get this added to the BI server documentation.
Thanks heaps, this is now enabled and working. Is there a way I can enable it from the command line / during the creation of the database? I am making the database like the below:
stardog-admin db create -n music
stardog-admin data-source add music.properties music_sql-to-stardog_mappings.ttl
stardog-admin virtual add --name music --data-source music music_sql-to-stardog_mappings.ttl
db create accepts a list of database options on the command line and you can enable virtual.transparency this way. It should be something like stardog-admin db create -o virtual.transparency=true -- -n music.