@SuppressWarnings("deprecation")
  @Test
  public void testAlterTableCascade() throws Exception {
    Table originalTable = partitionedTable;

    Table newTable = originalTable.deepCopy();
    List<FieldSchema> cols = newTable.getSd().getCols();
    cols.add(new FieldSchema("new_col_1", "int", null));

    // Run without cascade
    client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable, false);
    Table alteredTable = client.getTable(newTable.getDbName(), newTable.getTableName());
    Assert.assertEquals("The table data should be changed", newTable, alteredTable);

    List<Partition> partitions =
        client.listPartitions(originalTable.getDbName(), originalTable.getTableName(), (short)-1);
    for(Partition partition : partitions) {
      Assert.assertEquals("Partition columns should not be changed", 2,
          partition.getSd().getCols().size());
    }

    // Run with cascade
    cols.add(new FieldSchema("new_col_2", "int", null));
    client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable, true);
    alteredTable = client.getTable(newTable.getDbName(), newTable.getTableName());
    Assert.assertEquals("The table data should be changed", newTable, alteredTable);

    partitions =
        client.listPartitions(originalTable.getDbName(), originalTable.getTableName(), (short)-1);
    for(Partition partition : partitions) {
      Assert.assertEquals("Partition columns should be changed", 4,
          partition.getSd().getCols().size());
    }

    // Run using environment context with cascade
    cols.add(new FieldSchema("new_col_3", "int", null));
    EnvironmentContext context = new EnvironmentContext();
    context.putToProperties(StatsSetupConst.CASCADE, "true");
    client.alter_table_with_environmentContext(originalTable.getDbName(),
        originalTable.getTableName(), newTable, context);
    alteredTable = client.getTable(newTable.getDbName(), newTable.getTableName());
    Assert.assertEquals("The table data should be changed", newTable, alteredTable);

    partitions =
        client.listPartitions(originalTable.getDbName(), originalTable.getTableName(), (short)-1);
    for(Partition partition : partitions) {
      Assert.assertEquals("Partition columns should be changed", 5,
          partition.getSd().getCols().size());
    }
  }
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