@Override
  protected void doAlteration(Table table, Partition partition) throws HiveException {
    StorageDescriptor sd = getStorageDescriptor(table, partition);
    String serializationLib = sd.getSerdeInfo().getSerializationLib();
    AvroSerdeUtils.handleAlterTableForAvro(context.getConf(), serializationLib, table.getTTable().getParameters());

    List<FieldSchema> oldColumns = (partition == null ? table.getColsForMetastore() : partition.getColsForMetastore());
    List<FieldSchema> newColumns = desc.getNewColumns();

    if ("org.apache.hadoop.hive.serde.thrift.columnsetSerDe".equals(serializationLib)) {
      context.getConsole().printInfo("Replacing columns for columnsetSerDe and changing to LazySimpleSerDe");
      sd.getSerdeInfo().setSerializationLib(LazySimpleSerDe.class.getName());
      sd.setCols(newColumns);
    } else {
      // make sure the columns does not already exist
      for (FieldSchema newColumn : newColumns) {
        for (FieldSchema oldColumn : oldColumns) {
          if (oldColumn.getName().equalsIgnoreCase(newColumn.getName())) {
            throw new HiveException(ErrorMsg.DUPLICATE_COLUMN_NAMES, newColumn.getName());
          }
        }

        oldColumns.add(newColumn);
      }
      sd.setCols(oldColumns);
    }
  }
Operation process of adding some new columns.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/add/AlterTableAddColumnsOperation.java