Esempio n. 1
0
 @Test
 public final void testEmptyGroupSetStatement() {
   ParseTree tree = analyzer.parse(GROUP_BY[4]).getParseTree();
   assertEquals(StatementType.SELECT, tree.getType());
   QueryBlock block = (QueryBlock) tree;
   assertTrue(block.hasGroupbyClause());
   assertTrue(block.getGroupByClause().isEmptyGroupSet());
 }
Esempio n. 2
0
 @Test
 public final void testRollUpStatement() {
   ParseTree tree = analyzer.parse(GROUP_BY[2]).getParseTree();
   assertEquals(StatementType.SELECT, tree.getType());
   QueryBlock block = (QueryBlock) tree;
   assertTrue(block.hasGroupbyClause());
   assertEquals(1, block.getGroupByClause().getGroupSet().size());
   assertEquals(GroupType.ROLLUP, block.getGroupByClause().getGroupSet().get(0).getType());
   List<GroupElement> groups = block.getGroupByClause().getGroupSet();
   assertEquals("people.name", groups.get(0).getColumns()[0].getQualifiedName());
   assertEquals("people.age", groups.get(0).getColumns()[1].getQualifiedName());
 }
Esempio n. 3
0
 @Test
 public final void testGroupByStatement() {
   ParseTree tree = analyzer.parse(GROUP_BY[0]).getParseTree();
   assertEquals(StatementType.SELECT, tree.getType());
   QueryBlock block = (QueryBlock) tree;
   assertTrue(block.hasGroupbyClause());
   assertEquals(1, block.getGroupByClause().getGroupSet().size());
   assertEquals(
       "age", block.getGroupByClause().getGroupSet().get(0).getColumns()[0].getColumnName());
   assertTrue(block.hasHavingCond());
   assertEquals(Type.GTH, block.getHavingCond().getType());
 }
Esempio n. 4
0
 @Test
 public final void testMixedGroupByStatement() {
   ParseTree tree = analyzer.parse(GROUP_BY[3]).getParseTree();
   assertEquals(StatementType.SELECT, tree.getType());
   QueryBlock block = (QueryBlock) tree;
   assertTrue(block.hasGroupbyClause());
   assertEquals(3, block.getGroupByClause().getGroupSet().size());
   Iterator<GroupElement> it = block.getGroupByClause().getGroupSet().iterator();
   GroupElement group = it.next();
   assertEquals(GroupType.CUBE, group.getType());
   assertEquals("people.name", group.getColumns()[0].getQualifiedName());
   group = it.next();
   assertEquals(GroupType.ROLLUP, group.getType());
   assertEquals("people.age", group.getColumns()[0].getQualifiedName());
   group = it.next();
   assertEquals(GroupType.GROUPBY, group.getType());
   assertEquals("people.id", group.getColumns()[0].getQualifiedName());
 }