USGCRP / gcis-ontology

Ontology for the Global Change Information System
4 stars 7 forks source link

API, yasgui #119

Closed justgo129 closed 9 years ago

justgo129 commented 9 years ago

The query at: http://yasgui.org/short/41c-7Z99

returns outputs of "true."

However, running an identical query in the GCIS API returns an error: "Virtuoso 37000 Error SP031: SPARQL compiler: Variable 'findingStmt' is used in the query result set but not assigned."

I'm curious as to why this so. Is it a Virtuoso implementation issue?

zednis commented 9 years ago

The query in yasgui is flawed and yasgui ~should~ throw an error on it.

The function str( ) is being called on an unassigned variable - ?findingStmt

justgo129 commented 9 years ago

My understanding was that str() could be called on an unassigned variable if only used within the "select" portion of the query.

zednis commented 9 years ago

What would you expect it to return?

justgo129 commented 9 years ago

The string without the "xsd:..." suffix.

zednis commented 9 years ago

?findingStmt is never assigned a value at any point in that query. Case matters, and a variable with that case is not used anywhere in the query. ?findingStmt and ?findingstmt are different variables.

Perhaps you meant something like this? (I named the variables to reduce confusion)

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX gcis: <http://data.globalchange.gov/gcis.owl#>
PREFIX cito: <http://purl.org/spar/cito/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dbpprop: <http://dbpedia.org/property/>
SELECT distinct ?finding 
     str(?findingstmt) as ?stmt
from <http://data.globalchange.gov>
WHERE {
  ?finding a gcis:Finding .
  ?finding gcis:findingStatement ?findingstmt .
  FILTER NOT EXISTS { ?finding cito:cites ?work . ?work dbpprop:pubDate ?year . FILTER (?year > xsd:gYear("2009")) }
}
justgo129 commented 9 years ago

Ah, great, so case does matter. Thanks.

justgo129 commented 9 years ago

I'm curious as to why "true" in-lieu of something else was returned within yasgui though. I don't see a conditional statement other than the "FILTER NOT EXISTS" in the query. Is it responding to the line: "str(?findingstmt) as ?stmt" or to another one?

zednis commented 9 years ago

Case matters in the variables it does not matter in SPARQL keywords

SELECT ?x ?y { ... } ORDER BY ?x is the same as select ?x ?y { ... } order by ?x

?foo is a different variable from ?Foo

justgo129 commented 9 years ago

Got it, but I'm curious as to why "true" is returned (i.e. in-lieu of something else or an error message). Which portion of the code is being tested in order to return a true/false response?

zednis commented 9 years ago

@justgo129 I really don't know. That seems like a bug to me. I would expect an error message from YASGUI just as we got from the endpoint used by the GCIS API.

justgo129 commented 9 years ago

Works for me. Closed #119.