use of org.eclipse.rdf4j.query.algebra.QueryRoot in project incubator-rya by apache.
the class SparqlToPipelineTransformVisitorTest method testStatementPattern.
@Test
public void testStatementPattern() throws Exception {
QueryRoot query = new QueryRoot(new StatementPattern(new Var("x"), constant(RDF.TYPE), constant(UNDERGRAD)));
SparqlToPipelineTransformVisitor visitor = new SparqlToPipelineTransformVisitor(collection);
query.visit(visitor);
Assert.assertTrue(query.getArg() instanceof AggregationPipelineQueryNode);
AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) query.getArg();
Assert.assertEquals(Sets.newHashSet("x"), pipelineNode.getAssuredBindingNames());
}
use of org.eclipse.rdf4j.query.algebra.QueryRoot in project incubator-rya by apache.
the class SparqlToPigTransformVisitorTest method testMutliReturnJoin.
public void testMutliReturnJoin() throws Exception {
String query = "select * where {\n" + "?subj <urn:lubm:rdfts#name> 'Department0'.\n" + "?subj <urn:lubm:rdfts#subOrganizationOf> ?suborg.\n" + "}";
QueryParser parser = new SPARQLParser();
ParsedQuery parsedQuery = parser.parseQuery(query, null);
System.out.println(query);
SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
visitor.setTablePrefix(tablePrefix);
visitor.setInstance(instance);
visitor.setZk(zk);
visitor.setUser(user);
visitor.setPassword(password);
visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
System.out.println(visitor.getPigScript());
}
use of org.eclipse.rdf4j.query.algebra.QueryRoot in project incubator-rya by apache.
the class SparqlToPigTransformVisitorTest method testStatementPatternContextVar.
public void testStatementPatternContextVar() throws Exception {
String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + " PREFIX ub: <urn:lubm:rdfts#>\n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" + " SELECT * WHERE\n" + " {\n" + " GRAPH ?g {\n" + "\t?x rdf:type ub:UndergraduateStudent\n" + " }\n" + " ?x ub:pred ?g." + " }\n" + "";
QueryParser parser = new SPARQLParser();
ParsedQuery parsedQuery = parser.parseQuery(query, null);
// System.out.println(parsedQuery);
SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
visitor.setTablePrefix(tablePrefix);
visitor.setInstance(instance);
visitor.setZk(zk);
visitor.setUser(user);
visitor.setPassword(password);
visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
// System.out.println(visitor.getPigScript());
}
use of org.eclipse.rdf4j.query.algebra.QueryRoot in project incubator-rya by apache.
the class SparqlToPigTransformVisitorTest method testStatementPattern.
public void testStatementPattern() throws Exception {
String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + " PREFIX ub: <urn:lubm:rdfts#>\n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" + " SELECT * WHERE\n" + " {\n" + "\t?x rdf:type ub:UndergraduateStudent\n" + " }\n" + "";
QueryParser parser = new SPARQLParser();
ParsedQuery parsedQuery = parser.parseQuery(query, null);
// System.out.println(parsedQuery);
SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
visitor.setTablePrefix(tablePrefix);
visitor.setInstance(instance);
visitor.setZk(zk);
visitor.setUser(user);
visitor.setPassword(password);
visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
// System.out.println(visitor.getPigScript());
}
use of org.eclipse.rdf4j.query.algebra.QueryRoot in project incubator-rya by apache.
the class SparqlToPigTransformVisitorTest method testStatementPatternContext.
public void testStatementPatternContext() throws Exception {
String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + " PREFIX ub: <urn:lubm:rdfts#>\n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" + " SELECT * WHERE\n" + " {\n" + " GRAPH ub:g1 {\n" + "\t?x rdf:type ub:UndergraduateStudent\n" + " }\n" + " }\n" + "";
QueryParser parser = new SPARQLParser();
ParsedQuery parsedQuery = parser.parseQuery(query, null);
// System.out.println(parsedQuery);
SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
visitor.setTablePrefix(tablePrefix);
visitor.setInstance(instance);
visitor.setZk(zk);
visitor.setUser(user);
visitor.setPassword(password);
visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
// System.out.println(visitor.getPigScript());
}
Aggregations