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

multiple .required=FALSE statements #216

Open
lvaudor opened this issue Jun 21, 2024 · 1 comment
Open

multiple .required=FALSE statements #216

lvaudor opened this issue Jun 21, 2024 · 1 comment

Comments

@lvaudor
Copy link
Owner

lvaudor commented Jun 21, 2024

A weird thing is happening here:

spq_init() %>%
    spq_add("?flood wdt:P31/wdt:P279* wd:Q8068") %>% 
    spq_add("?flood wdt:P625 ?coords",.required=FALSE) %>%
    spq_add("?flood wdt:P17 ?country",.required=FALSE) %>%
    spq_add("?flood wdt:P1120 ?deathtoll",.required=FALSE) %>%
    spq_add("?flood wdt:P276 ?loc",.required=FALSE) %>% 
    spq_add("?loc wdt:P17 ?country_loc",.required=FALSE) %>% 
    spq_head(100)

When adding the last triplet (?loc wdt:P17 ?country_loc") the formerly partially empty loc column is filled with (wrong) values...

@lvaudor
Copy link
Owner Author

lvaudor commented Jun 21, 2024

OK the problem here seems to be that there should be nested OPTIONAL statements (just like what Maëlle did for spq_label on an optional variable)

This would work:


PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?coords ?coordsloc ?country ?deathtoll ?flood ?loc
WHERE {

?flood wdt:P31/wdt:P279* wd:Q8068.
OPTIONAL {?flood wdt:P625 ?coords.}
OPTIONAL {?flood wdt:P17 ?country.}
OPTIONAL {?flood wdt:P1120 ?deathtoll.}
OPTIONAL {?flood wdt:P276 ?loc.
         OPTIONAL{?loc wdt:P17 ?country_loc.}
         }
}

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