I have the following text towards the bottom of a named graph .ttl file (titled: <urn:customer-journey:model:026:model>
). The first object property definition is unimportant, other than I have the rules written after the classes, datatype, and object properties are defined in the .ttl file.
### MORE DEFINITIONS ABOVE
customer-journey:is_obsolete a owl:ObjectProperty ;
rdfs:comment "Filter by obsolete (OBS) \"Operator Status Code\"" ;
rdfs:label "is obsolete" ;
so:domainIncludes customer-journey:table_1 ;
so:rangeIncludes customer-journey:obsolete .
## Rule definitions
[
a <tag:stardog:api:rule:SPARQLRule> ;
rdfs:label "last event Rule" ;
<tag:stardog:api:rule:content> """IF {
{
?sub a <urn:customer-journey:model:table_3> .
?sub <urn:customer-journey:model:begin_date> ?dat_0 .
{
SELECT ?sub (MAX(?dat_0) AS ?lastEventDate)
WHERE {
?sub a <urn:customer-journey:model:table_3> .
?sub <urn:customer-journey:model:begin_date> ?dat_0 .
?current_date_table a <urn:customer-journey:model:hive_metastore.stardog.current_date_table> .
?current_date_table <urn:customer-journey:model:current_date> ?current_date .
FILTER(?dat_0 <= ?current_date)
} GROUP BY ?sub
}
FILTER (?dat_0 = ?lastEventDate) .
}
}
THEN {
?sub <urn:customer-journey:model:last_event> ?sub .
}"""
] .
### MORE RULES BELOW
This rule doesn't work (meaning that if I request the <urn:customer-journey:model:last_Event>
URN in a query, no records populate (however, if I remove it the query returns records)). However, a simpler one does:
[
a <tag:stardog:api:rule:SPARQLRule> ;
rdfs:label "upcoming event Rule" ;
<tag:stardog:api:rule:content> """IF {
{
?sub a <urn:customer-journey:model:table_3> .
?sub <urn:customer-journey:model:begin_date> ?dat_0 .
?current_date_table a <urn:customer-journey:model:hive_metastore.stardog.current_date_table> .
?current_date_table <urn:customer-journey:model:current_date> ?current_date .
?current_date_table <urn:customer-journey:model:future_date> ?future_date .
FILTER (?dat_0 > ?current_date && ?dat_0 <= ?future_date) .
}
}
THEN {
?sub <urn:customer-journey:model:upcoming_Event> ?sub .
}"""
] .
One thing to know is that the SPARQL query in the IF
statement of the last event rule
functions if run by itself (meaning as a query not within a rule).
Moreover, when I attempt to query for any rule (to see what the deal is) no results are produced. SPARQL query below:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
# Query Builder Search (SELECT)
SELECT ?rule
FROM <virtual://customer-journey>
FROM <urn:customer-journey:model:026:model>
WHERE {
?rule a <tag:stardog:api:rule:SPARQLRule> .
}
Is there an obvious bug in my code?