Null handling in SPARQL with StarDog


I have an event class with start and end dates and there is no end date triple for the event before its actual end. To select unfinished events, I usually do something like:

optional { ?s ontology:endDate ?endDate}
filter (?endDate = "")

However, with StarDog,that does not return anything. I have also used the following without success:

filter (str(?endDate) = "")
filter (strlen(str(?endDate)) = 0)
filter( isBLANK(?endDate) )
filter( ?endDate = UNDEF)
filter( ?endDate = NIL)

How can I handle null in StarDog?


If by NULL you mean there is no binding for ?endDate, then you want the following:

optional { ?s ontology:endDate ?endDate}
filter (!bound(?endDate))

Or, more concisely:

filter not exists { ?s ontology:endDate ?endDate }

The two solutions are working fine but the first one is faster.

Thanks for your fast answer Stephen!

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