예제 #1
0
  /** Test table operations */
  @Test
  public void testTableOps()
      throws MetaException, InvalidObjectException, NoSuchObjectException, InvalidInputException {
    Database db1 = new Database(DB1, "description", "locationurl", null);
    objectStore.createDatabase(db1);
    StorageDescriptor sd =
        new StorageDescriptor(
            null,
            "location",
            null,
            null,
            false,
            0,
            new SerDeInfo("SerDeName", "serializationLib", null),
            null,
            null,
            null);
    HashMap<String, String> params = new HashMap<String, String>();
    params.put("EXTERNAL", "false");
    Table tbl1 =
        new Table(
            TABLE1,
            DB1,
            "owner",
            1,
            2,
            3,
            sd,
            null,
            params,
            "viewOriginalText",
            "viewExpandedText",
            "MANAGED_TABLE");
    objectStore.createTable(tbl1);

    List<String> tables = objectStore.getAllTables(DB1);
    Assert.assertEquals(1, tables.size());
    Assert.assertEquals(TABLE1, tables.get(0));

    Table newTbl1 =
        new Table(
            "new" + TABLE1,
            DB1,
            "owner",
            1,
            2,
            3,
            sd,
            null,
            params,
            "viewOriginalText",
            "viewExpandedText",
            "MANAGED_TABLE");
    objectStore.alterTable(DB1, TABLE1, newTbl1);
    tables = objectStore.getTables(DB1, "new*");
    Assert.assertEquals(1, tables.size());
    Assert.assertEquals("new" + TABLE1, tables.get(0));

    objectStore.dropTable(DB1, "new" + TABLE1);
    tables = objectStore.getAllTables(DB1);
    Assert.assertEquals(0, tables.size());

    objectStore.dropDatabase(DB1);
  }
 @Override
 public void alterTable(String dbName, String name, Table newTable)
     throws InvalidObjectException, MetaException {
   objectStore.alterTable(dbName, name, newTable);
 }