@Test
  public void testAlterTable() throws Exception {
    Table originalTable = testTables[2];
    String originalTableName = originalTable.getTableName();
    String originalDatabase = originalTable.getDbName();

    Table newTable = getTableWithAllParametersSet();
    newTable.setTableName(originalTableName);
    newTable.setDbName(originalDatabase);
    // Partition keys can not be set, but getTableWithAllParametersSet is added one, so remove for
    // this test
    newTable.setPartitionKeys(originalTable.getPartitionKeys());
    client.alter_table(originalDatabase, originalTableName, newTable);
    Table alteredTable = client.getTable(originalDatabase, originalTableName);

    // The extra parameters will be added on server side, so check that the required ones are
    // present
    for(String key: newTable.getParameters().keySet()) {
      Assert.assertEquals("parameters are present", newTable.getParameters().get(key),
          alteredTable.getParameters().get(key));
    }
    // The parameters are checked manually, so do not check them
    newTable.setParameters(alteredTable.getParameters());

    // Some of the data is set on the server side, so reset those
    newTable.setCreateTime(alteredTable.getCreateTime());
    newTable.setCreationMetadata(alteredTable.getCreationMetadata());
    newTable.setWriteId(alteredTable.getWriteId());

    Assert.assertTrue(alteredTable.isSetId());
    alteredTable.unsetId();
    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