datacommonsorg/mixer

[BUG] SPARQL query for StatVar doesn't seem to handle empty values right

pradh opened this issue · 0 comments

pradh commented

This query does not return anything:

curl --request POST   --url https://api.datacommons.org/query   --header 'content-type: application/json'   --data '{
  "sparql": "SELECT ?date ?val ?unit ?period ?mmeth \
             WHERE { \
               ?obs typeOf StatVarObservation . \
               ?obs variableMeasured ?sv . \
               ?obs observationAbout ?pl . \
               ?obs observationDate ?date . \
               ?obs measurementMethod ?mmeth . \
               ?obs observationPeriod ?period . \
               ?obs unit ?unit . \
               ?obs value ?val . \
               ?pl typeOf Place . \
               ?pl mid \"/m/09c7w0\" . \
               ?sv typeOf StatisticalVariable . \
               ?sv p1 emittedThing . \
               ?sv v1 CarbonDioxide . \
               ?sv populationType Emissions . \
               ?sv measuredProperty amount . \
               ?sv statType measuredValue . \
               ?sv measurementDenominator PerCapita . \
               ?sv measurementQualifier \"\" . \
               ?sv numConstraints 1 . \
             } \
            LIMIT 10"
  }'

But if you remove the measurementQualifier triple, it works fine. There can be StatVars where the only difference is whether that field is null or not, and for that reason, its useful to assert it is empty.

My guess is that this is because the translator generates a SQL that checks for measurement_qualifier = "". It should probably check measurement_qualifier IS NULL.

image