comunica icon indicating copy to clipboard operation
comunica copied to clipboard

QueryEngine.query doesn't work for ASK when LIMIT is specified

Open balhoff opened this issue 1 year ago • 3 comments

Issue type:

  • :bug: Bug

Description:

I am using QueryEngine.query in my own application, to handle user entered queries of any type (SELECT, CONSTRUCT, ASK). I switch on the result type ('bindings', 'quads', 'boolean'). But when I submit an ASK query, 'boolean' is never encountered, and I get an error in the console: Invalid query output type: Expected 'bindings' or 'quads' but got 'boolean'.


Environment:

My app depends on "@comunica/query-sparql": "3.1.2", but I can also reproduce this in the main Comunica query demo at https://query.comunica.dev/#datasources=https%3A%2F%2Fquery.wikidata.org%2Fbigdata%2Fldf&query=ASK%0AWHERE%20%7B%0A%20%3Fs%20%3Fp%20%3Fo%20.%0A%7D%0ALIMIT%2010

Crash log:

balhoff avatar Jun 05 '24 20:06 balhoff

Thanks for reporting!

github-actions[bot] avatar Jun 05 '24 20:06 github-actions[bot]

Aha, now that I submitted this issue, I looked back at my demo query. I had not removed the LIMIT 10 from the ASK version. Removing this makes it work correctly. I just checked the SPARQL grammar and I think it says that a LIMIT is acceptable for ASK, although I'm not sure what effect it has.

balhoff avatar Jun 05 '24 20:06 balhoff

Ah, indeed, looks like our LIMIT implementation does not support ASK queries: https://github.com/comunica/comunica/blob/master/packages/actor-query-operation-slice/lib/ActorQueryOperationSlice.ts#L42-L60 Probably because there's not much value in using LIMIT on ASK, but it would be better for the engine to just ignore the LIMIT as opposed to crashing.

rubensworks avatar Jun 06 '24 06:06 rubensworks