-
Notifications
You must be signed in to change notification settings - Fork 577
Issue 166 in SPARQLWrapper solved #1900
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
Conversation
All changes I see is the addition of a commented function, maybe something is missing? If you are still working on a PR best to mark it as draft. |
Yes I was finalizing something, it is done now |
Many tests fail now: https://drone.rdflib.ashs.dev/RDFLib/rdflib/1685/1/2
Also this PR will need a test that reproduces the broken behavior for it to be merged. |
I have made the changes, now the tests which were earlier failing should not fail. I have also added the test file for reproducing the broken behavior. |
Looking good, all that's left to do in order to satisfy the automated contrib tests is to black the test file. |
Hi. Can you please explain what you mean by "blacking the test file" and how to do it? I am fairly new to open source contribution and haven't seen this term before. |
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
@PritishWadhwa this is what @gjhiggins meant I will review this when I can, before Sunday if possible. |
from rdflib import Graph | ||
|
||
|
||
def test_issue_166() -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just briefly, I would much rather prefer this goes into
rdflib/test/test_sparql/test_sparql.py
Lines 694 to 727 in eba1373
pytest.param( | |
""" | |
SELECT * WHERE { | |
BIND( | |
NOT EXISTS { | |
rdfs:Class rdfs:label "Class" | |
} | |
AS ?bound | |
) | |
} | |
""", | |
[{Variable('bound'): Literal(False)}], | |
id="select-bind-notexists-const-true", | |
), | |
], | |
) | |
def test_queries( | |
query_string: str, | |
expected_bindings: Sequence[Mapping["Variable", "Identifier"]], | |
rdfs_graph: Graph, | |
) -> None: | |
""" | |
Results of queries against the rdfs.ttl return the expected values. | |
""" | |
query_tree = parseQuery(query_string) | |
logging.debug("query_tree = %s", prettify_parsetree(query_tree)) | |
logging.debug("query_tree = %s", query_tree) | |
query = translateQuery(query_tree) | |
logging.debug("query = %s", query) | |
query._original_args = (query_string, {}, None) | |
result = rdfs_graph.query(query) | |
logging.debug("result = %s", result) | |
assert expected_bindings == result.bindings |
Appologies but this will only be reviewed in W20 as #1891 is taking most of my time and I have other priorities also. |
Sure, No worries! |
Just a note, to link this PR to an issue please see: The way you are doing it makes more involved to find the issue you are referring to. |
I'm going to first merge typing from #1850 before merging these fixes, this will be in smallish PRs like: Once these are merged you should rebase this. In general though the tests should still be integrated. Furthermore, I think it may be better to use dict or OrderedDict instead of list and a set: https://stackoverflow.com/a/53657523/1598080 |
Sure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comments.
Please rebase this branch onto master or merge master into this branch. |
If there is nothing further on this PR I will close it. |
Closing this PR due to inactivity, feel free to open it again if you continue working on it again. |
Closing this PR due to inactivity, feel free to open it again if you continue working on it again. |
The order of ResultRows for a SELECT * query was randomized and was changing. This is unexpected because other SPARQL engines seem to generally apply the order of variables as they occur in the WHERE block.
Sample code:
query="SELECT * { ?a ?b ?c } LIMIT 10"
qres=g.query(query)
print(qres.vars)
Expected output:
[rdflib.term.Variable('a'), rdflib.term.Variable('b'), rdflib.term.Variable('c')]
Real output:
[rdflib.term.Variable('c'), rdflib.term.Variable('a'), rdflib.term.Variable('b')] (first run)
[rdflib.term.Variable('a'), rdflib.term.Variable('b'), rdflib.term.Variable('c')] (second run)
[rdflib.term.Variable('b'), rdflib.term.Variable('a'), rdflib.term.Variable('c')] (third run)
[rdflib.term.Variable('a'), rdflib.term.Variable('c'), rdflib.term.Variable('b')] (fourth run)
[you get the idea]
(Tested on the HDT edition of DBpedia 2016, created with g = rdflib.Graph(store=rdflib_hdt.HDTStore(rdf_file)), but that shouldn't matter.)
This was corrected without interfering with the time complexity and the output is now as it should be (as shown in the expected output)