-
Notifications
You must be signed in to change notification settings - Fork 654
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
NPE in OpAsQuery #2883
Comments
The example has several moving parts: @Test
public void testSubQuery01() {
test_roundTripQuery("SELECT ?z { SELECT ?x { } }");
} focuses on the subquery part. |
I added your query to the PR but it was not failing before. The issue seems to be related to (NOT) EXISTS. I found more strange things going on (tested with the PR applied which only passes on an expr transform which otherwise might result in NPE): # TestOpAsQuery.java
@Test
public void testExists08a() {
String queryStr = """
SELECT * {
FILTER NOT EXISTS { SELECT * { ?s a ?t } LIMIT 2 }
}
""";
Query inputQuery = QueryFactory.create(queryStr);
Op op = Algebra.compile(inputQuery);
System.out.println("Original Op: " + op);
// Output looks OK to me:
// (filter (notexists
// (slice _ 2
// (bgp (triple ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?t))))
// (table unit))
Query queryFromOriginalOp = OpAsQuery.asQuery(op);
System.out.println("Query from original op: " + queryFromOriginalOp);
// Output looks OK to me - Note that an empty graph pattern was injected but that should be fine:
// SELECT * WHERE { { }
// FILTER NOT EXISTS { SELECT * WHERE { ?s a ?t } LIMIT 2 } }
Op parsedOp = SSE.parseOp(op.toString());
System.out.println("Parse op " + parsedOp);
// Output looks OK to me:
// (filter (notexists
// (slice _ 2
// (bgp (triple ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?t))))
// (table unit))
Query queryFromParsedOp = OpAsQuery.asQuery(parsedOp);
System.out.println("Query from parsed op: " + queryFromParsedOp);
// Now there is a warning and the SLICE 2 got lost
// WARN ElementTransformer :: Attempt to transform a null element - ignored
// Query from parsed op: SELECT *
// WHERE
// { { }
// FILTER NOT EXISTS { ?s a ?t }
// }
} 😮 So something seems to break with the Op/Element duality in Also: @Test
public void testExists08b() {
String opStr = """
(filter (notexists
(slice _ 2
(bgp (triple ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?t))))
(table unit)
)
""";
test_AlgebraToQuery(opStr, "SELECT * { { } FILTER NOT EXISTS { SELECT * { ?s a ?t } LIMIT 2 } }");
} gives
|
The aforementioned issue #2883 (comment) should now be fixed in the proposed PR. |
Version
5.3.0-SNAPSHOT
What happened?
The following query fails an
OpAsQuery
roundtrip due to an NPE:Relevant output and stacktrace
Are you interested in making a pull request?
Yes
The text was updated successfully, but these errors were encountered: