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

GH-4859 Add instead of remove QueryRoot for explaining optimized Sail queries #4862

Merged

Conversation

frensjan
Copy link
Contributor

@frensjan frensjan commented Dec 23, 2023

GitHub issue resolved: #4859

Briefly describe the changes proposed in this PR:

This change adds instead of removes QueryRoot in SailQuery#explain to support explanations of queries of which the root TupleExpr is replaced.


PR Author Checklist (see the contributor guidelines for more details):

  • my pull request is self-contained
  • I've added tests for the changes I made
  • I've applied code formatting (you can use mvn process-resources to format from the command line)
  • I've squashed my commits where necessary
  • every commit message starts with the issue number (GH-xxxx) followed by a meaningful description of the change

@@ -148,4 +152,21 @@ public void testPrepareBooleanQuery_bypassed() {
verify(sailConnection).evaluate(eq(expr), any(), any(), anyBoolean());
}

@Test
public void testExplainQuery() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I struggled a bit with the use of Mockito here.

Explanation explanation = mock(Explanation.class);

when(sailConnection.prepareQuery(any(), any(), any(), any())).thenReturn(Optional.of(expr));
when(sailConnection.explain(any(), any(TupleExpr.class), any(), any(), anyBoolean(), anyInt()))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to write

when(sailConnection.explain(any(), eq(expr), any(), any(), anyBoolean(), anyInt()))

here. Note the eq(expr).

TupleQuery query = subject.prepareTupleQuery("SELECT * WHERE { ?s ?p ?o }");
assertThat(query.explain(Explanation.Level.Unoptimized)).isEqualTo(explanation);

verify(sailConnection).explain(eq(Explanation.Level.Unoptimized), any(QueryRoot.class), any(), any(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here I wanted to use

verify(sailConnection).explain(eq(Explanation.Level.Unoptimized), eq(new QueryRoot(expr)), any(), any(),
				anyBoolean(), anyInt());

but that didn't work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine as it is.

@hmottestad
Copy link
Contributor

I see that you've targeted develop. That will make this part of 5.0.0 (or the next milestone build). If you need it sooner you can branch & target the main branch instead. Let me know what you want!

@frensjan frensjan force-pushed the GH-4859-explain-with-query-root branch from 510f14a to cc3782c Compare January 8, 2024 11:12
@frensjan frensjan changed the base branch from develop to main January 8, 2024 11:12
@frensjan
Copy link
Contributor Author

frensjan commented Jan 8, 2024

I've changed the base to target main instead. Thanks @hmottestad.

As an aside, is there a rough idea on when 5.0 will land?

@hmottestad hmottestad closed this Jan 13, 2024
@hmottestad hmottestad reopened this Jan 13, 2024
@hmottestad
Copy link
Contributor

Had to close and reopen this to trigger the CI.

@hmottestad hmottestad merged commit 1d47c5a into eclipse-rdf4j:main Jan 13, 2024
8 of 9 checks passed
@hmottestad
Copy link
Contributor

I've changed the base to target main instead. Thanks @hmottestad.

As an aside, is there a rough idea on when 5.0 will land?

I'm still working on integrating support for JSON-LD 1.1. Once that is complete I'll publish the final milestone build and allow for a few weeks to let users test it out and make sure things are functional.

I'll have a bug fix release out in a week or so I reckon, it'll include your fix here.

@frensjan
Copy link
Contributor Author

I've changed the base to target main instead. Thanks @hmottestad.
As an aside, is there a rough idea on when 5.0 will land?

I'm still working on integrating support for JSON-LD 1.1. Once that is complete I'll publish the final milestone build and allow for a few weeks to let users test it out and make sure things are functional.

I'll have a bug fix release out in a week or so I reckon, it'll include your fix here.

Cool! Can't wait to get al the deprecation warnings out of our code base 😉

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

Successfully merging this pull request may close these issues.

Stripping QueryRoot when using query explanation
2 participants