BlueBrain / nexus-forge

Building and Using Knowledge Graphs made easy
https://nexus-forge.readthedocs.io
GNU Lesser General Public License v3.0
38 stars 19 forks source link

KnowledgeGraphForge.sparql(query, rewrite=False) rewrites LIMIT #262

Closed joni-herttuainen closed 1 year ago

joni-herttuainen commented 2 years ago

Issue When doing a sparql(..., rewrite=False) call, the LIMIT written in the query string is not reinforced, it needs to be manually fed as a keyword argument. Is this the expected behavior?

I would have expected that rewrite=False would guarantee the query string is not manipulated.

This seems to affect at least the latest release and the current version in master.

Repro

query = 
"""
# PREFIXES
SELECT ?id WHERE {
    ?id a nsg:DetailedCircuit
} LIMIT 1
"""
forge.sparql(query, debug=True, rewrite=False)

Debug output:

PREFIXES
SELECT ?id WHERE {
    ?id a nsg:DetailedCircuit
} LIMIT 100

To get what I expected:

query = 
"""
# PREFIXES
SELECT ?id WHERE {
    ?id a nsg:DetailedCircuit
}
"""
forge.sparql(query, debug=True, rewrite=False, limit=1)
crisely09 commented 1 year ago

I have a possible (and straightforward) solution: keep the query as given when rewrite=False, specifically the limit and offset parameters, and print a warning if any of these parameters is passed to the method, announcing they won't be taken into account because rewrite was set to False.

crisely09 commented 1 year ago

Also, it would be good to not have any limit, and just use what is given in the query, or even have an option to not have a limit.