Should this Sparql querry work?

Hi there,

when creating a simple virtual graph with this mapping:

@prefix dexpi: <http://www.aixcape.org/oimel/dexpi.owl#> .
@prefix sm: <tag:stardog:api:mapping:> .
@prefix rr: <http://www.w3.org/ns/r2rml#> .

<#Pump> 
rr:sqlQuery """
SELECT [PnPID]
  FROM[dbo].[Pumps]
""" .

<#ADPUMPMAP>
    rr:logicalTable <#Pump>;
    rr:subjectMap [
        rr:template "http://autocad.bayer.com/equipment/{PnPID}";
        rr:class dexpi:Pump;
    ].

And in the dexpi owl file it is specified that pump is a subclass of equipment, I would have thought that when executing the following query I should get a result, but I don’t get any:

SELECT ?eqp
{ 
	GRAPH <virtual://autocad> 
	{ 
		?eqp a dexpi:Equipment . 
	} 
}

Did I make a mistake? Is the query wrong ? Is it possible that way

Best regards Ben

I’d have to look over the spec but I’m not sure if a plain subjectmap is a valid mapping. You can try rewriting it to include a predicateObjectMap with either some additional triple, a dummy triple or you could probably just double up the class assertion. Give that a try and see if that works for you. ( it would be cool if there was an ICV for R2RML files. Something that’s on my list of things to do )

Hi,

my current workaround is indeed to assign the class pump and Equipment to make sure the SPARQL query works. My question is: Is it possible to only map a subclass and than query only the superior class ?

Nevertheless I also tried a different mapping:

<#ACPEquipmentTableView> 
rr:sqlQuery """
SELECT 
	[PnPID]
	,[Tag] as EQPTAG
  FROM 
	[dbo].[Equipment]
  WHERE
	[Tag] like '%BA%'
	
""".

<#ADPEQPMAP>
    rr:logicalTable <#ACPEquipmentTableView>;
    rr:subjectMap [
        rr:template "http://autocad.bayer.com/equipment/{PnPID}";
        rr:class dexpi:Vessel;
    ];
        rr:predicateObjectMap [
        rr:predicate dexpi:TagNameAssignmentClass_of_TaggedPlantItem;
        rr:objectMap [ rr:column "EQPTAG" ];
    ].

And than tried to query it, with no results. (Vessel is also a subclass of Equipment)

SELECT ?eqp

{ 
	GRAPH <virtual://autocad> 
	{ 
		?eqp a dexpi:Vessel .
	}
}

Hi Ben,

This is certainly possible. Did you run your query with reasoning enabled? Can you share the query plan?

Jess

Hi Jess,

I just checked to be sure, reasoning is enabled. Can you sent me a link or a an instruction on how to access the query plan of my query?

Ben

You should run stardog query explain instead of stardog query execute. You can view the man page here.

Jess

Just wanted to followup that indeed a single SubjectMap is a perfectly fine mapping. I should have know that if I had thought about it for a second. I just don’t see it very often.

A couple of other things you might want to look at. What is your setting for reasoning.schema.graphs. You might not have loaded your schema in a place that Stardog is look for it. You can try adding a single triple in your main database

:test a dexpi:Vessel

and query against that just to confirm that reasoning is working. (I’ve had plenty of times where things weren’t working as expected and there was some silly typo that was messing things up)

Try checking the setting in the webconsole under “Reasoning over virtual graphs and service clauses” is on. I don’t know that the property setting for this is and couldn’t find it in the documentation. I doubt that it’s the problem since the default is “On” but worth checking.

ps: Got it. The property is reasoning.virtual.graph.enabled

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