driver.run(String.format("alter table %s rename to %s", tblName, renamed));
listSize++;
assertEquals(notifyList.size(), listSize);
Table renamedTable = msc.getTable(dbName, renamed);
AlterTableEvent alterTableE = (AlterTableEvent) notifyList.get(listSize-1);
assert alterTableE.getStatus();
Table oldTable = alterTableE.getOldTable();
Table newTable = alterTableE.getNewTable();
assertEquals(tbl.getDbName(), oldTable.getDbName());
assertEquals(tbl.getTableName(), oldTable.getTableName());
assertEquals(tbl.getSd().getLocation(), oldTable.getSd().getLocation());
assertEquals(renamedTable.getDbName(), newTable.getDbName());
assertEquals(renamedTable.getTableName(), newTable.getTableName());
assertEquals(renamedTable.getSd().getLocation(), newTable.getSd().getLocation());
//change the table name back
driver.run(String.format("alter table %s rename to %s", renamed, tblName));
listSize++;
assertEquals(notifyList.size(), listSize);
driver.run(String.format("alter table %s ADD COLUMNS (c int)", tblName));
listSize++;
assertEquals(notifyList.size(), listSize);
Table altTable = msc.getTable(dbName, tblName);
alterTableE = (AlterTableEvent) notifyList.get(listSize-1);
assert alterTableE.getStatus();
oldTable = alterTableE.getOldTable();
List<FieldSchema> origCols = tbl.getSd().getCols();
List<FieldSchema> oldCols = oldTable.getSd().getCols();
List<FieldSchema> altCols = altTable.getSd().getCols();
List<FieldSchema> newCols = altTable.getSd().getCols();
Iterator<FieldSchema> i = origCols.iterator();
Iterator<FieldSchema> j = oldCols.iterator();
while (i.hasNext()) {
assertEquals(i.next().getName(), j.next().getName());
}
i = altCols.iterator();
j = newCols.iterator();
while (i.hasNext()) {
String name = i.next().getName();
assertEquals(name, j.next().getName());
}
newTable = alterTableE.getNewTable();
assertEquals(tbl.getDbName(), oldTable.getDbName());
assertEquals(tbl.getTableName(), oldTable.getTableName());
assertEquals(tbl.getSd().getLocation(), oldTable.getSd().getLocation());
assertEquals(altTable.getDbName(), newTable.getDbName());
assertEquals(altTable.getTableName(), newTable.getTableName());