Ejemplo n.º 1
0
  @Test
  public final void testCreateTableAsSelect() {
    CreateTableStmt stmt = (CreateTableStmt) analyzer.parse(createTableStmts[3]).getParseTree();
    assertEquals("store1", stmt.getTableName());
    testOrderByCluse(stmt.getSelectStmt());

    stmt = (CreateTableStmt) analyzer.parse(createTableStmts[4]).getParseTree();
    assertEquals("store1", stmt.getTableName());
    testOrderByCluse(stmt.getSelectStmt());
    assertTrue(stmt.hasTableDef());

    stmt = (CreateTableStmt) analyzer.parse(createTableStmts[5]).getParseTree();
    assertEquals("store2", stmt.getTableName());
    assertEquals(StoreType.RCFILE, stmt.getStoreType());
    assertEquals("4096", stmt.getOptions().get("rcfile.buffer"));
    testOrderByCluse(stmt.getSelectStmt());
  }
Ejemplo n.º 2
0
 @Test
 public final void testCreateTableDef2() {
   CreateTableStmt stmt = (CreateTableStmt) analyzer.parse(createTableStmts[7]).getParseTree();
   assertEquals("table1", stmt.getTableName());
   Schema def = stmt.getTableDef();
   assertEquals("name", def.getColumn(0).getColumnName());
   assertEquals(DataType.STRING, def.getColumn(0).getDataType());
   assertEquals("age", def.getColumn(1).getColumnName());
   assertEquals(DataType.INT, def.getColumn(1).getDataType());
   assertEquals("earn", def.getColumn(2).getColumnName());
   assertEquals(DataType.LONG, def.getColumn(2).getDataType());
   assertEquals("score", def.getColumn(3).getColumnName());
   assertEquals(DataType.FLOAT, def.getColumn(3).getDataType());
   assertEquals(StoreType.CSV, stmt.getStoreType());
   assertEquals("/tmp/data", stmt.getPath().toString());
   assertTrue(stmt.hasOptions());
   assertEquals("|", stmt.getOptions().get("csv.delimiter"));
 }
Ejemplo n.º 3
0
 @Test
 public final void testCreateTableDef1() {
   CreateTableStmt stmt = (CreateTableStmt) analyzer.parse(createTableStmts[6]).getParseTree();
   assertEquals("table1", stmt.getTableName());
   Schema def = stmt.getTableDef();
   assertEquals("name", def.getColumn(0).getColumnName());
   assertEquals(DataType.STRING, def.getColumn(0).getDataType());
   assertEquals("age", def.getColumn(1).getColumnName());
   assertEquals(DataType.INT, def.getColumn(1).getDataType());
   assertEquals("earn", def.getColumn(2).getColumnName());
   assertEquals(DataType.LONG, def.getColumn(2).getDataType());
   assertEquals("score", def.getColumn(3).getColumnName());
   assertEquals(DataType.FLOAT, def.getColumn(3).getDataType());
   assertEquals(StoreType.RCFILE, stmt.getStoreType());
   assertFalse(stmt.hasPath());
   assertTrue(stmt.hasOptions());
   assertEquals("4096", stmt.getOptions().get("rcfile.buffer"));
 }
Ejemplo n.º 4
0
  @Test
  public final void testCreateTable1() {
    CreateTableStmt stmt = (CreateTableStmt) analyzer.parse(createTableStmts[0]).getParseTree();
    assertEquals("table1", stmt.getTableName());
    assertTrue(stmt.hasDefinition());

    stmt = (CreateTableStmt) analyzer.parse(createTableStmts[1]).getParseTree();
    assertEquals("table1", stmt.getTableName());
    assertTrue(stmt.hasDefinition());
    assertTrue(stmt.hasStoreType());
    assertEquals(StoreType.RCFILE, stmt.getStoreType());

    stmt = (CreateTableStmt) analyzer.parse(createTableStmts[2]).getParseTree();
    assertEquals("table1", stmt.getTableName());
    assertTrue(stmt.hasDefinition());
    assertTrue(stmt.hasStoreType());
    assertEquals(StoreType.RCFILE, stmt.getStoreType());
    assertTrue(stmt.hasOptions());
    assertEquals("4096", stmt.getOptions().get("rcfile.buffer"));
  }