QueryJoinOptimizer implements QueryOptimizer { @Override public void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings) { tupleExpr.visit(new JoinVisitor()); } QueryJoinOptimizer();  QueryJoinOptimizer(EvaluationStatistics statistics); @Override void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings);  }
@Test public void testSES2116JoinBind() throws Exception { StringBuilder qb = new StringBuilder(); qb.append("SELECT ?subject ?name ?row {\n" + " ?subject <http: + " BIND(STR(?uri) AS ?name)\n" + " ?table <http: + " ?table <http: SPARQLParser parser = new SPARQLParser(); ParsedQuery q = parser.parseQuery(qb.toString(), null); QueryJoinOptimizer opt = new QueryJoinOptimizer(); QueryRoot optRoot = new QueryRoot(q.getTupleExpr()); opt.optimize(optRoot, null, null); TupleExpr leaf = findLeaf(optRoot); Assert.assertTrue("Extension must be evaluated before StatementPattern", leaf.getParentNode() instanceof Extension); }
@Test public void bindSubselectJoinOrder() throws Exception { String query = "SELECT * WHERE {\n" + " BIND (bnode() as ?ct01) \n" + " { SELECT ?s WHERE {\n" + " ?s ?p ?o .\n" + " }\n" + " LIMIT 10\n" + " }\n" + "}"; SPARQLParser parser = new SPARQLParser(); ParsedQuery q = parser.parseQuery(query, null); QueryJoinOptimizer opt = new QueryJoinOptimizer(); QueryRoot optRoot = new QueryRoot(q.getTupleExpr()); opt.optimize(optRoot, null, null); JoinFinder joinFinder = new JoinFinder(); optRoot.visit(joinFinder); Join join = joinFinder.getJoin(); assertThat(join.getLeftArg()).as("BIND clause should be left-most argument of join") .isInstanceOf(Extension.class); }