SMS2 for Cosmos using CDATA JDBC Driver

We try to virtually map JSON data from Cosmos to Stardog using the CDATA JDBC Driver. The following script works:

PREFIX : <http://api.stardog.com/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX stardog: <tag:stardog:api:>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

MAPPING
FROM SQL {
  SELECT *
  FROM [myDB].[myFile]
}
TO {
  ?subject <http://api.stardog.com/tenantconfig#prop1> ?value_1 .
  ?subject <http://api.stardog.com/tenantconfig#prop2> ?value_2 .
} WHERE {
  BIND(template("http://api.stardog.com/my_namespace/{value_1}") AS ?subject)
}

However, the JSON data is nested. E.g., the example structure looks like the following:

{
"prop1" : "value_1",
 "prop2" : {[
                "prop2_1" : "value_2_1",
                "prop2_2" : "value_2_2",
                ]}
}         

Is there a way to apply the "FROM JSON" mapper techniques together with the "FROM SQL"? The goal would be to have resulting RDF like the following:

  ?subject <http://api.stardog.com/tenantconfig#prop1> ?value_1 .
  ?subject <http://api.stardog.com/tenantconfig#prop2_1> ?value_2_1 .
  ?subject <http://api.stardog.com/tenantconfig#prop2_2> ?value_2_2 .

Is this possible using the JDBC Driver? Or would we have to use a Mongo one?

The MongoDB driver is the supported one, though we do support many of the other CData drivers. If you do choose to try the CData driver then you must use FROM SQL. Any JSON to relational mapping will have to be done through the CData schema mapping file, though, as indicated, this is not the supported method for accessing MongoDB/CosmoDB from Stardog.

-Paul

Thanks, Paul.

Just to clarifiy for a slightly different input. I guess there is no way to catch all the elements of the list "prop2" using the "FROM SQL" route, is there?

E.g., in a "From JSON" section one can do that like that:

FROM JSON {
{
"prop1" : "value_1",
 "prop2" : {[
                    {"id" : "?my_id"},
                    {"id" : "?my_id"}
                ]}
}
} TO {
?s :has_prop2 ?my_id         

I am struggling to do a similar thing here. At what point could I use the schema mappring approach from CData? Or ist this rather a CData related question?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.