Feature/384 bridge where compiler#466
Conversation
|
Test Results 424 files 424 suites 31s ⏱️ Results for commit 2123acc. ♻️ This comment has been updated with latest results. |
| * A query-side {@link Edge} produced by the WHERE compiler from a | ||
| * {@link fr.inria.corese.core.next.query.impl.sparql.ast.TriplePatternAst}. | ||
| */ | ||
| final class AstBackedEdge implements Edge { |
There was a problem hiding this comment.
AstBackedEdge currently inherits the default Edge.contains(Node) implementation, which always returns false. For query edges we probably need contains() to match subject/object, otherwise some runtime logic may not see that this pattern carries these variables.
@Test
void edgeContainsSubjectAndObject() {
Node subject = new NodeImpl(Variable.create("s"));
Node predicate = new NodeImpl(Variable.create("p"));
Node object = new NodeImpl(Variable.create("o"));
AstBackedEdge edge = new AstBackedEdge(subject, predicate, object);
assertTrue(edge.contains(subject));
assertTrue(edge.contains(object));
}| Node endpoint = toNode(service.endpoint()); | ||
| Exp endpointNode = Exp.create(Type.NODE, endpoint); | ||
| Exp body = compile(service.pattern()); | ||
| Exp exp = Exp.create(Type.SERVICE, endpointNode, body); |
There was a problem hiding this comment.
SERVICE is currently compiled with a plain AND body. However, next runtime seems to execute SERVICE through exp.rest().getQuery(), which is null for an AND. So the current structure looks valid in the unit test, but may not match the runtime contract expected for service execution.
Replace SERVICE(endpoint, AND(...)) by SERVICE(endpoint, QUERY(...))
@Test
void serviceRestShouldExposeAQueryForRuntime() {
ServiceAst service = new ServiceAst(
new IriAst("<http://example.org/>"),
false,
group(new BgpAst(List.of(
new TriplePatternAst(new VarAst("s"), new VarAst("p"), new VarAst("o"))))));
Exp serviceExp = new WhereCompiler().compile(service);
assertTrue(serviceExp.isService());
assertNotNull(serviceExp.rest().getQuery(), "SERVICE runtime expects a query body");
}| Node variable = toNode(bind.variable()); | ||
| Exp exp = Exp.create(Type.BIND); | ||
| exp.setFilter(filter); | ||
| exp.setNode(variable); |
There was a problem hiding this comment.
BIND does not propagate the filter functional flag here. For Corese-specific expressions such as unnest or sql (not standard SPARQL), filter.isFunctional() becomes true, but exp.isFunctional() stays false, so runtime may take the non-functional execution path.
@Test
void bindShouldPropagateFunctionalFlag() {
BindAst bind = new BindAst(
new FunctionCallAst(new IriAst("<http://example.org/unnest>"), List.of(new VarAst("x"))),
new VarAst("y"));
Exp bindExp = new WhereCompiler().compile(bind);
assertTrue(bindExp.getFilter().isFunctional());
assertTrue(bindExp.isFunctional(), "BIND exp should propagate functional flag");
}| * {@link fr.inria.corese.core.next.query.impl.sparql.ast.TriplePatternAst}. | ||
| */ | ||
| final class AstBackedEdge implements Edge { | ||
|
|
There was a problem hiding this comment.
For variable predicates, AstBackedEdge does not expose the predicate through getEdgeVariable(). next runtime uses edge.getEdgeVariable() in query bookkeeping, so a pattern like ?s ?p ?o may not register ?p the same way as existing query edges do.
@Test
void edgeExposesVariablePredicateAsEdgeVariable() {
Exp bgp = new WhereCompiler().compile(new BgpAst(List.of(
new TriplePatternAst(new VarAst("s"), new VarAst("p"), new VarAst("o")))));
Exp edgeExp = bgp.get(0);
assertNotNull(edgeExp.getEdge().getEdgeVariable(), "variable predicate should be exposed as edge variable");
assertTrue(edgeExp.getEdge().getEdgeVariable().isVariable());
}
|
MaillPierre
left a comment
There was a problem hiding this comment.
Auto-approve on comment reply
| } | ||
|
|
||
| @Override | ||
| public Node getGraph() { |
There was a problem hiding this comment.
Should it return something ? either the default graph or the encompassing graph
SELECT * {
<a> <b> <c>
}
The <a> <b> <c> edge graph is either null of DefaultGraphURI
SELECT * {
GRAPH <g> {
<a> <b> <c>
}
}
The <a> <b> <c> edge graph is <g>
81576ac to
32fe0bf
Compare
|
32fe0bf to
2123acc
Compare
|
| private Exp compileService(ServiceAst service) { | ||
| Node endpoint = toNode(service.endpoint()); | ||
| Exp endpointNode = Exp.create(Type.NODE, endpoint); | ||
| Query body = Query.create(compile(service.pattern())); |
There was a problem hiding this comment.
SERVICE now wraps its body in a Query, which fixes exp.rest().getQuery(), but the body query is still not marked as a service query. In the legacy compiler we explicitly call q.setService(true), and that matters because non-service queries may inherit outer FROM / NAMED clauses. So the current shape may still execute SERVICE with the wrong dataset later. For consistency with the legacy compiler, it may also be worth propagating the SILENT flag to the body query.
@Test
void serviceBodyShouldBeMarkedAsServiceQuery() {
ServiceAst service = new ServiceAst(
new IriAst("<http://example.org/>"),
false,
group(new BgpAst(List.of(
new TriplePatternAst(new VarAst("s"), new VarAst("p"), new VarAst("o"))))));
Exp serviceExp = new WhereCompiler().compile(service);
assertTrue(serviceExp.rest().getQuery().isService(),
"SERVICE body query should be marked as service");
}private Exp compileService(ServiceAst service) {
Node endpoint = toNode(service.endpoint());
Exp endpointNode = Exp.create(Type.NODE, endpoint);
Query body = Query.create(compile(service.pattern()));
body.setService(true);
body.setSilent(service.silent());
Exp exp = Exp.create(Type.SERVICE, endpointNode, body);
exp.setSilent(service.silent());
return exp;
}
|
No description provided.