@Test
  public void testAlterTableChangeCols() throws Exception {
    Table originalTable = partitionedTable;

    Table newTable = originalTable.deepCopy();

    List<FieldSchema> cols = newTable.getSd().getCols();
    // Change a column
    cols.get(0).setName("modified_col");
    // Remove a column
    cols.remove(1);
    // Add a new column
    cols.add(new FieldSchema("new_col", "int", null));
    // Store the changes
    client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
    Table alteredTable = client.getTable(newTable.getDbName(), newTable.getTableName());
    Assert.assertTrue("Original table directory should be kept",
        metaStore.isPathExists(new Path(originalTable.getSd().getLocation())));

    // The following data might be changed
    alteredTable.setParameters(newTable.getParameters());
    Assert.assertEquals("The table data should be the same", newTable, alteredTable);

    // Modify partition column type, and comment
    newTable.getPartitionKeys().get(0).setType("string");
    newTable.getPartitionKeys().get(0).setComment("changed comment");

    client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
    alteredTable = client.getTable(newTable.getDbName(), newTable.getTableName());
    // The following data might be changed
    alteredTable.setParameters(newTable.getParameters());
    Assert.assertEquals("The table data should be the same", newTable, alteredTable);
  }
This test creates and queries a table and then drops it. Good for testing the happy path
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java