Search code examples
c#sparqldotnetrdf

Debugging sparql function return values in dotNetRDF


I have a SPARQL query with a filter that looks something like:

SELECT * FROM 
{
    ...

    data:person_1  app:maxDistance  ?value
    data:person_1  app:coordinates  ?coord1
    data:person_2  app:coordinates  ?coord2

    FILTER (
         xsd:float(STRBEFORE(?value, " miles"))
            >=
         app:miles-between(?coord1, ?coord2)
    )
} 

?value here is a literal in the form "x miles" (x being a numeric quantity)

so I want to filter out people that are farther away than the person_1's maxDistance, however it seems the filter always returns false and nobody is ever filtered out.

The problem is though I'm not sure how to debug this. I know the return value of app:miles-between since it's custom c# function that I can breakpoint in and see that is correctly returns a double value.

However I don't know what xsd:float() and STRBEFORE return. Is there anyway to bind the return value to a variable and output from SELECT?

I tried using the ExplainQueryProcessor but it doesn't give me enough information, such as the return values I want to know.


Solution

  • However I don't know what xsd:float() and STRBEFORE return. Is there anyway to bind the return value to a variable and output from SELECT?

    You want BIND:

    select ?floatValue ?milesBetween where {
      …
      BIND( xsd:float(STRBEFORE(?value, " miles")) as ?floatValue )
      BIND( app:miles-between(?coord1, ?coord2) as ?milesBetween )
    }