public void testPipe2() throws ZException, ZQLException { ZQL zql = new ZQL(); zql.append("select <X:1,Y:2> from bank | test1"); ZPlan plan = zql.compile(); assertEquals(1, plan.size()); assertEquals("select <X:1,Y:2> from bank", plan.get(0).prev().getQuery()); plan.get(0).release(); }
public void testNestedGtLt() throws ZException, ZQLException { ZQL zql = new ZQL(); zql.append("select <STRUCT<ARRAY> asdf> asdf; select * from a;"); List<Z> plan = zql.compile(); assertEquals(2, plan.size()); assertEquals("select <STRUCT<ARRAY> asdf> asdf", plan.get(0).getQuery()); assertEquals("select * from a", plan.get(1).getQuery()); }
public void testGtLt() throws ZException, ZQLException { ZQL zql = new ZQL(); zql.append("select * from bank where age > 10 and age < 20; select * from a;"); List<Z> plan = zql.compile(); assertEquals(2, plan.size()); assertEquals("select * from bank where age > 10 and age < 20", plan.get(0).getQuery()); assertEquals("select * from a", plan.get(1).getQuery()); }
public void testPipe() throws ZException, ZQLException { ZQL zql = new ZQL(); zql.append("select * from bank | select * from <%= z." + Q.INPUT_VAR_NAME + " %> limit 10"); ZPlan plan = zql.compile(); assertEquals(1, plan.size()); assertEquals( "select * from " + plan.get(0).prev().name() + " limit 10", plan.get(0).getQuery()); plan.get(0).release(); }
public void testSemicolon() throws ZException, ZQLException { ZQL zql = new ZQL(); zql.append( "create table if not exists bank(a INT); select * from bank | select * from <%= z." + Q.INPUT_VAR_NAME + " %> limit 10; show tables; "); List<Z> plan = zql.compile(); assertEquals(3, plan.size()); assertEquals( "select * from " + plan.get(1).prev().name() + " limit 10", plan.get(1).getQuery()); assertEquals("show tables", plan.get(2).getQuery()); for (Z query : plan) { assertNotNull(query.getConnection()); } }