示例#1
0
  @Test
  public void testValidateFails() throws SqlParseException {
    Planner planner = getPlanner();
    SqlNode parse = planner.parse("select * from \"emps\" where \"Xname\" like '%e%'");
    assertThat(
        parse.toString(), equalTo("SELECT *\n" + "FROM `emps`\n" + "WHERE `Xname` LIKE '%e%'"));

    try {
      SqlNode validate = planner.validate(parse);
      fail("expected error, got " + validate);
    } catch (ValidationException e) {
      assertThat(Util.getStackTrace(e), containsString("Column 'Xname' not found in any table"));
      // ok
    }
  }
示例#2
0
  @Test
  public void testParseAndConvert() throws Exception {
    Planner planner = getPlanner();
    SqlNode parse = planner.parse("select * from \"emps\" where \"name\" like '%e%'");
    assertThat(
        parse.toString(), equalTo("SELECT *\n" + "FROM `emps`\n" + "WHERE `name` LIKE '%e%'"));

    SqlNode validate = planner.validate(parse);
    RelNode rel = planner.convert(validate);
    assertThat(
        toString(rel),
        equalTo(
            "ProjectRel(empid=[$0], deptno=[$1], name=[$2], salary=[$3], commission=[$4])\n"
                + "  FilterRel(condition=[LIKE($2, '%e%')])\n"
                + "    EnumerableTableAccessRel(table=[[hr, emps]])\n"));
  }