public void alterTable(String catName, String dbName, String tblName, Table newTbl, boolean cascade,
      EnvironmentContext environmentContext, boolean transactional, long replWriteId)
      throws HiveException {

    if (catName == null) {
      catName = getDefaultCatalog(conf);
    }
    try {
      // Remove the DDL_TIME so it gets refreshed
      if (newTbl.getParameters() != null) {
        newTbl.getParameters().remove(hive_metastoreConstants.DDL_TIME);
      }
      if (environmentContext == null) {
        environmentContext = new EnvironmentContext();
      }
      if (isRename(environmentContext)) {
        newTbl.validateName(conf);
        environmentContext.putToProperties(HiveMetaHook.OLD_TABLE_NAME, tblName);
        environmentContext.putToProperties(HiveMetaHook.OLD_DB_NAME, dbName);
      } else {
        newTbl.checkValidity(conf);
      }
      if (cascade) {
        environmentContext.putToProperties(StatsSetupConst.CASCADE, StatsSetupConst.TRUE);
      }

      // Take a table snapshot and set it to newTbl.
      AcidUtils.TableSnapshot tableSnapshot = null;
      if (transactional) {
        if (replWriteId > 0) {
          // We need a valid writeId list for a transactional table modification. During
          // replication we do not have a valid writeId list which was used to modify the table
          // on the source. But we know for sure that the writeId associated with it was valid
          // then (otherwise modification would have failed on the source). So use a valid
          // transaction list with only that writeId.
          ValidWriteIdList writeIds = new ValidReaderWriteIdList(TableName.getDbTable(dbName, tblName),
                                                                  new long[0], new BitSet(),
                                                                  replWriteId);
          tableSnapshot = new TableSnapshot(replWriteId, writeIds.writeToString());
        } else {
          // Make sure we pass in the names, so we can get the correct snapshot for rename table.
          tableSnapshot = AcidUtils.getTableSnapshot(conf, newTbl, dbName, tblName, true);
        }
        if (tableSnapshot != null) {
          newTbl.getTTable().setWriteId(tableSnapshot.getWriteId());
        } else {
          LOG.warn("Cannot get a table snapshot for " + tblName);
        }
      }

      // Why is alter_partitions synchronized while this isn't?
      getMSC().alter_table(
          catName, dbName, tblName, newTbl.getTTable(), environmentContext,
          tableSnapshot == null ? null : tableSnapshot.getValidWriteIdList());
    } catch (MetaException e) {
      throw new HiveException("Unable to alter table. " + e.getMessage(), e);
    } catch (TException e) {
      throw new HiveException("Unable to alter table. " + e.getMessage(), e);
    }
  }
Updates the existing table metadata with the new metadata.

@param fullyQlfdTblName
         name of the existing table
@param newTbl
         new name of the table. could be the old name
@param transactional
         Need to generate and save a table snapshot into the metastore?
@throws HiveException
ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java