Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pradh opened this issue Aug 19, 2021 · 0 comments
Open

Comments

@pradh
Copy link
Contributor

pradh commented Aug 19, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant