@Override
  protected void doAlteration(Table table, Partition partition) throws HiveException {
    StorageDescriptor sd = getStorageDescriptor(table, partition);
    // change SerDe to LazySimpleSerDe if it is columnsetSerDe
    String serializationLib = sd.getSerdeInfo().getSerializationLib();
    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());
    } else if (!VALID_SERIALIZATION_LIBS.contains(serializationLib)) {
      throw new HiveException(ErrorMsg.CANNOT_REPLACE_COLUMNS, desc.getDbTableName());
    }

    // adding columns and limited integer type promotion is not supported for ORC schema evolution
    boolean isOrcSchemaEvolution = serializationLib.equals(OrcSerde.class.getName()) &&
        AlterTableUtils.isSchemaEvolutionEnabled(table, context.getConf());
    if (isOrcSchemaEvolution) {
      List<FieldSchema> existingCols = sd.getCols();
      List<FieldSchema> replaceCols = desc.getNewColumns();

      if (replaceCols.size() < existingCols.size()) {
        throw new HiveException(ErrorMsg.REPLACE_CANNOT_DROP_COLUMNS, desc.getDbTableName());
      }
    }

    boolean droppingColumns = desc.getNewColumns().size() < sd.getCols().size();
    if (ParquetHiveSerDe.isParquetTable(table) && AlterTableUtils.isSchemaEvolutionEnabled(table, context.getConf()) &&
        !desc.isCascade() && droppingColumns && table.isPartitioned()) {
      LOG.warn("Cannot drop columns from a partitioned parquet table without the CASCADE option");
      throw new HiveException(ErrorMsg.DROP_COLUMN_UNCASCADED, desc.getDbTableName());
    }

    sd.setCols(desc.getNewColumns());
  }
Operation process of replacing two columns.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/column/replace/AlterTableReplaceColumnsOperation.java