@Test
public void testSelect() {

  Parser<Relation> parser = RelationParser.select(ExpressionParser.NUMBER, ExpressionParser.NUMBER, TABLE);
  TerminalParserTest.assertParser(parser, "select distinct 1, 2 as id from t1, t2",
      new Select(true, 
          Arrays.asList(new Projection(ExpressionParserTest.number(1), null), new Projection(ExpressionParserTest.number(2), "id")),
          Arrays.asList(table("t1"), table("t2")),
          null, null, null));
  TerminalParserTest.assertParser(parser, "select 1 as id from t where 1",
      new Select(false, 
          Arrays.asList(new Projection(ExpressionParserTest.number(1), "id")),
          Arrays.asList(table("t")),
          ExpressionParserTest.number(1), null, null));
  TerminalParserTest.assertParser(parser, "select 1 as id from t group by 2, 3",
      new Select(false, 
          Arrays.asList(new Projection(ExpressionParserTest.number(1), "id")),
          Arrays.asList(table("t")),
          null, new GroupBy(Arrays.asList(ExpressionParserTest.number(2), ExpressionParserTest.number(3)), null), null));
  TerminalParserTest.assertParser(parser, "select 1 as id from t group by 2, 3 having 4",
      new Select(false, 
          Arrays.asList(new Projection(ExpressionParserTest.number(1), "id")),
          Arrays.asList(table("t")),
          null, new GroupBy(Arrays.asList(ExpressionParserTest.number(2), ExpressionParserTest.number(3)), ExpressionParserTest.number(4)), null));
  TerminalParserTest.assertParser(parser, "select 1 as id from t order by 2 asc, 3 desc",
      new Select(false, 
          Arrays.asList(new Projection(ExpressionParserTest.number(1), "id")),
          Arrays.asList(table("t")),
          null, null, new OrderBy(Arrays.asList(
              new OrderBy.Item(ExpressionParserTest.number(2), true), new OrderBy.Item(ExpressionParserTest.number(3), false)))));
}