All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.hadoop.hive.ql.plan.AlterTableDesc Maven / Gradle / Ivy

There is a newer version: 1.21.1
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.hadoop.hive.ql.plan;

import org.apache.hadoop.hive.ql.io.AcidUtils;

import org.apache.hadoop.hive.metastore.api.EnvironmentContext;
import org.apache.hadoop.hive.metastore.api.FieldSchema;
import org.apache.hadoop.hive.metastore.api.Order;
import org.apache.hadoop.hive.metastore.api.SQLCheckConstraint;
import org.apache.hadoop.hive.metastore.api.SQLDefaultConstraint;
import org.apache.hadoop.hive.metastore.api.SQLForeignKey;
import org.apache.hadoop.hive.metastore.api.SQLNotNullConstraint;
import org.apache.hadoop.hive.metastore.api.SQLPrimaryKey;
import org.apache.hadoop.hive.metastore.api.SQLUniqueConstraint;
import org.apache.hadoop.hive.ql.exec.Utilities;
import org.apache.hadoop.hive.ql.metadata.Table;
import org.apache.hadoop.hive.ql.parse.ParseUtils;
import org.apache.hadoop.hive.ql.parse.ReplicationSpec;
import org.apache.hadoop.hive.ql.parse.SemanticException;
import org.apache.hadoop.hive.ql.plan.Explain.Level;
import hive.com.google.common.collect.ImmutableList;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * AlterTableDesc.
 *
 */
@Explain(displayName = "Alter Table", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
public class AlterTableDesc extends DDLDesc implements Serializable, DDLDesc.DDLDescWithWriteId {
  private static final long serialVersionUID = 1L;

  /**
   * alterTableTypes.
   *
   */
  public static enum AlterTableTypes {
    RENAME("rename"), ADDCOLS("add columns"), REPLACECOLS("replace columns"),
    ADDPROPS("add props"), DROPPROPS("drop props"), ADDSERDE("add serde"), ADDSERDEPROPS("add serde props"),
    ADDFILEFORMAT("add fileformat"), ADDCLUSTERSORTCOLUMN("add cluster sort column"),
    RENAMECOLUMN("rename column"), ADDPARTITION("add partition"), TOUCH("touch"), ARCHIVE("archieve"),
    UNARCHIVE("unarchieve"), ALTERLOCATION("alter location"),
    DROPPARTITION("drop partition"), RENAMEPARTITION("rename partition"), ADDSKEWEDBY("add skew column"),
    ALTERSKEWEDLOCATION("alter skew location"), ALTERBUCKETNUM("alter bucket number"),
    ALTERPARTITION("alter partition"), COMPACT("compact"),
    TRUNCATE("truncate"), MERGEFILES("merge files"), DROPCONSTRAINT("drop constraint"), ADDCONSTRAINT("add constraint"),
    UPDATECOLUMNS("update columns"), OWNER("set owner");
    ;

    private final String name;
    private AlterTableTypes(String name) { this.name = name; }
    public String getName() { return name; }

    public static final List nonNativeTableAllowedTypes = 
        ImmutableList.of(ADDPROPS, DROPPROPS, ADDCOLS);
  }

  public static enum ProtectModeType {
    NO_DROP, OFFLINE, READ_ONLY, NO_DROP_CASCADE
  }

  public static final Set alterTableTypesWithPartialSpec =
      new HashSet();

  static {
    alterTableTypesWithPartialSpec.add(AlterTableDesc.AlterTableTypes.ADDCOLS);
    alterTableTypesWithPartialSpec.add(AlterTableDesc.AlterTableTypes.REPLACECOLS);
    alterTableTypesWithPartialSpec.add(AlterTableDesc.AlterTableTypes.RENAMECOLUMN);
    alterTableTypesWithPartialSpec.add(AlterTableDesc.AlterTableTypes.ADDPROPS);
    alterTableTypesWithPartialSpec.add(AlterTableDesc.AlterTableTypes.DROPPROPS);
    alterTableTypesWithPartialSpec.add(AlterTableDesc.AlterTableTypes.ADDSERDE);
    alterTableTypesWithPartialSpec.add(AlterTableDesc.AlterTableTypes.ADDSERDEPROPS);
    alterTableTypesWithPartialSpec.add(AlterTableDesc.AlterTableTypes.ADDFILEFORMAT);
  }

  AlterTableTypes op;
  String oldName;
  String newName;
  ArrayList newCols;
  String serdeName;
  HashMap props;
  String inputFormat;
  String outputFormat;
  String storageHandler;
  int numberBuckets;
  ArrayList bucketColumns;
  ArrayList sortColumns;

  String oldColName;
  String newColName;
  String newColType;
  String newColComment;
  boolean first;
  String afterCol;
  boolean expectView;
  HashMap partSpec;
  private String newLocation;
  boolean protectModeEnable;
  ProtectModeType protectModeType;
  Map, String> skewedLocations;
  boolean isTurnOffSkewed = false;
  boolean isStoredAsSubDirectories = false;
  List skewedColNames;
  List> skewedColValues;
  Table tableForSkewedColValidation;
  boolean isDropIfExists = false;
  boolean isTurnOffSorting = false;
  boolean isCascade = false;
  EnvironmentContext environmentContext;
  String dropConstraintName;
  List primaryKeyCols;
  List foreignKeyCols;
  List uniqueConstraintCols;
  List notNullConstraintCols;
  List defaultConstraintsCols;
  List checkConstraintsCols;
  ReplicationSpec replicationSpec;
  private Long writeId = null;
  PrincipalDesc ownerPrincipal;

  public AlterTableDesc() {
  }

  /**
   * @param tblName
   *          table name
   * @param oldColName
   *          old column name
   * @param newColName
   *          new column name
   * @param newComment
   * @param newType
   * @throws SemanticException
   */
  public AlterTableDesc(String tblName, HashMap partSpec,
      String oldColName, String newColName, String newType, String newComment,
      boolean first, String afterCol, boolean isCascade) throws SemanticException {
    super();
    setOldName(tblName);
    this.partSpec = partSpec;
    this.oldColName = oldColName;
    this.newColName = newColName;
    newColType = newType;
    newColComment = newComment;
    this.first = first;
    this.afterCol = afterCol;
    op = AlterTableTypes.RENAMECOLUMN;
    this.isCascade = isCascade;
  }

  public AlterTableDesc(String tblName, HashMap partSpec,
      String oldColName, String newColName, String newType, String newComment,
      boolean first, String afterCol, boolean isCascade, List primaryKeyCols,
      List foreignKeyCols, List uniqueConstraintCols,
      List notNullConstraintCols, List defaultConstraints,
                        List checkConstraints) throws SemanticException {
    super();
    setOldName(tblName);
    this.partSpec = partSpec;
    this.oldColName = oldColName;
    this.newColName = newColName;
    newColType = newType;
    newColComment = newComment;
    this.first = first;
    this.afterCol = afterCol;
    op = AlterTableTypes.RENAMECOLUMN;
    this.isCascade = isCascade;
    this.primaryKeyCols = primaryKeyCols;
    this.foreignKeyCols = foreignKeyCols;
    this.uniqueConstraintCols = uniqueConstraintCols;
    this.notNullConstraintCols = notNullConstraintCols;
    this.defaultConstraintsCols = defaultConstraints;
    this.checkConstraintsCols = checkConstraints;
  }

  /**
   * @param oldName
   *          old name of the table
   * @param newName
   *          new name of the table
   * @param expectView
   *          Flag to denote if current table can be a view
   * @param replicationSpec
   *          Replication specification with current event ID
   * @throws SemanticException
   */
  public AlterTableDesc(String oldName, String newName, boolean expectView, ReplicationSpec replicationSpec) throws SemanticException {
    op = AlterTableTypes.RENAME;
    setOldName(oldName);
    this.newName = newName;
    this.expectView = expectView;
    this.replicationSpec = replicationSpec;
  }

  /**
   * @param name
   *          name of the table
   * @param newCols
   *          new columns to be added
   * @throws SemanticException
   */
  public AlterTableDesc(String name, HashMap partSpec, List newCols,
      AlterTableTypes alterType, boolean isCascade) throws SemanticException {
    op = alterType;
    setOldName(name);
    this.newCols = new ArrayList(newCols);
    this.partSpec = partSpec;
    this.isCascade = isCascade;
  }

  /**
   * @param alterType
   *          type of alter op
   * @param replicationSpec
   *          Replication specification with current event ID
   */
  public AlterTableDesc(AlterTableTypes alterType, ReplicationSpec replicationSpec) {
    op = alterType;
    this.replicationSpec = replicationSpec;
  }

  /**
   * @param alterType
   *          type of alter op
   */
  public AlterTableDesc(AlterTableTypes alterType) {
    this(alterType, null, false);
  }

  /**
   * @param alterType
   *          type of alter op
   * @param expectView
   *          Flag to denote if current table can be a view
   * @param partSpec
   *          Partition specifier with map of key and values.
   */
  public AlterTableDesc(AlterTableTypes alterType, HashMap partSpec, boolean expectView) {
    op = alterType;
    this.partSpec = partSpec;
    this.expectView = expectView;
  }

  /**
   *
   * @param name
   *          name of the table
   * @param inputFormat
   *          new table input format
   * @param outputFormat
   *          new table output format
   * @param partSpec
   * @throws SemanticException
   */
  public AlterTableDesc(String name, String inputFormat, String outputFormat,
      String serdeName, String storageHandler, HashMap partSpec) throws SemanticException {
    super();
    op = AlterTableTypes.ADDFILEFORMAT;
    setOldName(name);
    this.inputFormat = inputFormat;
    this.outputFormat = outputFormat;
    this.serdeName = serdeName;
    this.storageHandler = storageHandler;
    this.partSpec = partSpec;
  }

  public AlterTableDesc(String tableName, int numBuckets,
      List bucketCols, List sortCols, HashMap partSpec) throws SemanticException {
    setOldName(tableName);
    op = AlterTableTypes.ADDCLUSTERSORTCOLUMN;
    numberBuckets = numBuckets;
    bucketColumns = new ArrayList(bucketCols);
    sortColumns = new ArrayList(sortCols);
    this.partSpec = partSpec;
  }

  public AlterTableDesc(String tableName, boolean sortingOff, HashMap partSpec) throws SemanticException {
    setOldName(tableName);
    op = AlterTableTypes.ADDCLUSTERSORTCOLUMN;
    isTurnOffSorting = sortingOff;
    this.partSpec = partSpec;
  }

  public AlterTableDesc(String tableName, String newLocation,
      HashMap partSpec) throws SemanticException {
    op = AlterTableTypes.ALTERLOCATION;
    setOldName(tableName);
    this.newLocation = newLocation;
    this.partSpec = partSpec;
  }

  public AlterTableDesc(String tableName, Map, String> locations,
      HashMap partSpec) throws SemanticException {
    op = AlterTableTypes.ALTERSKEWEDLOCATION;
    setOldName(tableName);
    this.skewedLocations = locations;
    this.partSpec = partSpec;
  }

  public AlterTableDesc(String tableName, boolean turnOffSkewed,
      List skewedColNames, List> skewedColValues) throws SemanticException {
    setOldName(tableName);
    op = AlterTableTypes.ADDSKEWEDBY;
    this.isTurnOffSkewed = turnOffSkewed;
    this.skewedColNames = new ArrayList(skewedColNames);
    this.skewedColValues = new ArrayList>(skewedColValues);
  }

  public AlterTableDesc(String tableName, HashMap partSpec, int numBuckets) throws SemanticException {
    op = AlterTableTypes.ALTERBUCKETNUM;
    setOldName(tableName);
    this.partSpec = partSpec;
    this.numberBuckets = numBuckets;
  }

  public AlterTableDesc(String tableName, String dropConstraintName, ReplicationSpec replicationSpec) throws SemanticException {
    setOldName(tableName);
    this.dropConstraintName = dropConstraintName;
    this.replicationSpec = replicationSpec;
    op = AlterTableTypes.DROPCONSTRAINT;
  }

  public AlterTableDesc(String tableName, List primaryKeyCols,
          List foreignKeyCols, List uniqueConstraintCols,
          ReplicationSpec replicationSpec) throws SemanticException {
    setOldName(tableName);
    this.primaryKeyCols = primaryKeyCols;
    this.foreignKeyCols = foreignKeyCols;
    this.uniqueConstraintCols = uniqueConstraintCols;
    this.replicationSpec = replicationSpec;
    op = AlterTableTypes.ADDCONSTRAINT;
  }

  public AlterTableDesc(String tableName, List primaryKeyCols,
      List foreignKeyCols, List uniqueConstraintCols,
      List notNullConstraintCols, List defaultConstraints,
                        List checkConstraints, ReplicationSpec replicationSpec) throws SemanticException {
    setOldName(tableName);
    this.primaryKeyCols = primaryKeyCols;
    this.foreignKeyCols = foreignKeyCols;
    this.uniqueConstraintCols = uniqueConstraintCols;
    this.notNullConstraintCols = notNullConstraintCols;
    this.defaultConstraintsCols = defaultConstraints;
    this.checkConstraintsCols = checkConstraints;
    this.replicationSpec = replicationSpec;
    op = AlterTableTypes.ADDCONSTRAINT;
  }

  public AlterTableDesc(String tableName, PrincipalDesc ownerPrincipal) {
    op  = AlterTableTypes.OWNER;
    this.oldName = tableName;
    this.ownerPrincipal = ownerPrincipal;
  }

  /**
   * @param ownerPrincipal the owner principal of the table
   */
  public void setOwnerPrincipal(PrincipalDesc ownerPrincipal) {
    this.ownerPrincipal = ownerPrincipal;
  }

  @Explain(displayName="owner")
  public PrincipalDesc getOwnerPrincipal() {
    return this.ownerPrincipal;
  }

  @Explain(displayName = "new columns", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
  public List getNewColsString() {
    return Utilities.getFieldSchemaString(getNewCols());
  }

  @Explain(displayName = "type", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
  public String getAlterTableTypeString() {
    return op.getName();
  }

  /**
   * @return the old name of the table
   */
  @Explain(displayName = "old name", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
  public String getOldName() {
    return oldName;
  }

  /**
   * @param oldName
   *          the oldName to set
   */
  public void setOldName(String oldName) throws SemanticException {
    // Make sure we qualify the name from the outset so there's no ambiguity.
    this.oldName = String.join(".", Utilities.getDbTableName(oldName));
  }

  /**
   * @return the newName
   */
  @Explain(displayName = "new name", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
  public String getNewName() {
    return newName;
  }

  /**
   * @param newName
   *          the newName to set
   */
  public void setNewName(String newName) {
    this.newName = newName;
  }

  /**
   * @return the op
   */
  public AlterTableTypes getOp() {
    return op;
  }

  /**
   * @param op
   *          the op to set
   */
  public void setOp(AlterTableTypes op) {
    this.op = op;
  }

  /**
   * @return the newCols
   */
  public ArrayList getNewCols() {
    return newCols;
  }

  /**
   * @param newCols
   *          the newCols to set
   */
  public void setNewCols(ArrayList newCols) {
    this.newCols = newCols;
  }

  /**
   * @return the serdeName
   */
  @Explain(displayName = "deserializer library")
  public String getSerdeName() {
    return serdeName;
  }

  /**
   * @param serdeName
   *          the serdeName to set
   */
  public void setSerdeName(String serdeName) {
    this.serdeName = serdeName;
  }

  /**
   * @return the props
   */
  @Explain(displayName = "properties")
  public HashMap getProps() {
    return props;
  }

  /**
   * @param props
   *          the props to set
   */
  public void setProps(HashMap props) {
    this.props = props;
  }

  /**
   * @return the input format
   */
  @Explain(displayName = "input format", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
  public String getInputFormat() {
    return inputFormat;
  }

  /**
   * @param inputFormat
   *          the input format to set
   */
  public void setInputFormat(String inputFormat) {
    this.inputFormat = inputFormat;
  }

  /**
   * @return the output format
   */
  @Explain(displayName = "output format", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
  public String getOutputFormat() {
    return outputFormat;
  }

  /**
   * @param outputFormat
   *          the output format to set
   */
  public void setOutputFormat(String outputFormat) {
    this.outputFormat = outputFormat;
  }

  /**
   * @return the storage handler
   */
  @Explain(displayName = "storage handler", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
  public String getStorageHandler() {
    return storageHandler;
  }

  /**
   * @param primaryKeyCols
   *          the primary key cols to set
   */
  public void setPrimaryKeyCols(List primaryKeyCols) {
    this.primaryKeyCols = primaryKeyCols;
  }

  /**
   * @return the primary key cols
   */
  public List getPrimaryKeyCols() {
    return primaryKeyCols;
  }

  /**
   * @param foreignKeyCols
   *          the foreign key cols to set
   */
  public void setForeignKeyCols(List foreignKeyCols) {
    this.foreignKeyCols = foreignKeyCols;
  }

  /**
   * @return the foreign key cols
   */
  public List getForeignKeyCols() {
    return foreignKeyCols;
  }

  /**
   * @return the unique constraint cols
   */
  public List getUniqueConstraintCols() {
    return uniqueConstraintCols;
  }

  /**
   * @return the not null constraint cols
   */
  public List getNotNullConstraintCols() {
    return notNullConstraintCols;
  }

  /**
   * @return the default constraint cols
   */
  public List getDefaultConstraintCols() {
    return defaultConstraintsCols;
  }

  /**
   * @return the check constraint cols
   */
  public List getCheckConstraintCols() { return checkConstraintsCols; }

  /**
   * @return the drop constraint name of the table
   */
  @Explain(displayName = "drop constraint name", explainLevels = { Level.USER, Level.DEFAULT, Level.EXTENDED })
  public String getConstraintName() {
    return dropConstraintName;
  }

  /**
   * @param constraintName
   *          the dropConstraintName to set
   */
  public void setDropConstraintName(String constraintName) {
    this.dropConstraintName = constraintName;
  }

  /**
   * @param storageHandler
   *          the storage handler to set
   */
  public void setStorageHandler(String storageHandler) {
    this.storageHandler = storageHandler;
  }

  /**
   * @return the number of buckets
   */
  public int getNumberBuckets() {
    return numberBuckets;
  }

  /**
   * @param numberBuckets
   *          the number of buckets to set
   */
  public void setNumberBuckets(int numberBuckets) {
    this.numberBuckets = numberBuckets;
  }

  /**
   * @return the bucket columns
   */
  public ArrayList getBucketColumns() {
    return bucketColumns;
  }

  /**
   * @param bucketColumns
   *          the bucket columns to set
   */
  public void setBucketColumns(ArrayList bucketColumns) {
    this.bucketColumns = bucketColumns;
  }

  /**
   * @return the sort columns
   */
  public ArrayList getSortColumns() {
    return sortColumns;
  }

  /**
   * @param sortColumns
   *          the sort columns to set
   */
  public void setSortColumns(ArrayList sortColumns) {
    this.sortColumns = sortColumns;
  }

  /**
   * @return old column name
   */
  public String getOldColName() {
    return oldColName;
  }

  /**
   * @param oldColName
   *          the old column name
   */
  public void setOldColName(String oldColName) {
    this.oldColName = oldColName;
  }

  /**
   * @return new column name
   */
  public String getNewColName() {
    return newColName;
  }

  /**
   * @param newColName
   *          the new column name
   */
  public void setNewColName(String newColName) {
    this.newColName = newColName;
  }

  /**
   * @return new column type
   */
  public String getNewColType() {
    return newColType;
  }

  /**
   * @param newType
   *          new column's type
   */
  public void setNewColType(String newType) {
    newColType = newType;
  }

  /**
   * @return new column's comment
   */
  public String getNewColComment() {
    return newColComment;
  }

  /**
   * @param newComment
   *          new column's comment
   */
  public void setNewColComment(String newComment) {
    newColComment = newComment;
  }

  /**
   * @return if the column should be changed to position 0
   */
  public boolean getFirst() {
    return first;
  }

  /**
   * @param first
   *          set the column to position 0
   */
  public void setFirst(boolean first) {
    this.first = first;
  }

  /**
   * @return the column's after position
   */
  public String getAfterCol() {
    return afterCol;
  }

  /**
   * @param afterCol
   *          set the column's after position
   */
  public void setAfterCol(String afterCol) {
    this.afterCol = afterCol;
  }

  /**
   * @return whether to expect a view being altered
   */
  public boolean getExpectView() {
    return expectView;
  }

  /**
   * @param expectView
   *          set whether to expect a view being altered
   */
  public void setExpectView(boolean expectView) {
    this.expectView = expectView;
  }

  /**
   * @return part specification
   */
  public HashMap getPartSpec() {
    return partSpec;
  }

  /**
   * @param partSpec
   */
  public void setPartSpec(HashMap partSpec) {
    this.partSpec = partSpec;
  }

  /**
   * @return new location
   */
  public String getNewLocation() {
    return newLocation;
  }

  /**
   * @param newLocation new location
   */
  public void setNewLocation(String newLocation) {
    this.newLocation = newLocation;
  }

  public boolean isProtectModeEnable() {
    return protectModeEnable;
  }

  public void setProtectModeEnable(boolean protectModeEnable) {
    this.protectModeEnable = protectModeEnable;
  }

  public ProtectModeType getProtectModeType() {
    return protectModeType;
  }

  public void setProtectModeType(ProtectModeType protectModeType) {
    this.protectModeType = protectModeType;
  }
  /**
   * @return the skewedLocations
   */
  public Map, String> getSkewedLocations() {
    return skewedLocations;
  }

  /**
   * @param skewedLocations the skewedLocations to set
   */
  public void setSkewedLocations(Map, String> skewedLocations) {
    this.skewedLocations = skewedLocations;
  }

  /**
   * @return isTurnOffSorting
   */
  public boolean isTurnOffSorting() {
    return isTurnOffSorting;
  }

  /**
   * @return the turnOffSkewed
   */
  public boolean isTurnOffSkewed() {
    return isTurnOffSkewed;
  }

  /**
   * @param turnOffSkewed the turnOffSkewed to set
   */
  public void setTurnOffSkewed(boolean turnOffSkewed) {
    this.isTurnOffSkewed = turnOffSkewed;
  }

  /**
   * @return the skewedColNames
   */
  public List getSkewedColNames() {
    return skewedColNames;
  }

  /**
   * @param skewedColNames the skewedColNames to set
   */
  public void setSkewedColNames(List skewedColNames) {
    this.skewedColNames = skewedColNames;
  }

  /**
   * @return the skewedColValues
   */
  public List> getSkewedColValues() {
    return skewedColValues;
  }

  /**
   * @param skewedColValues the skewedColValues to set
   */
  public void setSkewedColValues(List> skewedColValues) {
    this.skewedColValues = skewedColValues;
  }

  /**
   * Validate alter table description.
   *
   * @throws SemanticException
   */
  public void validate() throws SemanticException {
    if (null != tableForSkewedColValidation) {
      /* Validate skewed information. */
      ValidationUtility.validateSkewedInformation(
          ParseUtils.validateColumnNameUniqueness(tableForSkewedColValidation.getCols()),
          this.getSkewedColNames(), this.getSkewedColValues());
    }
  }

  /**
   * @param table the table to set
   */
  public void setTable(Table table) {
    this.tableForSkewedColValidation = table;
  }

  /**
   * @return the isStoredAsSubDirectories
   */
  public boolean isStoredAsSubDirectories() {
    return isStoredAsSubDirectories;
  }

  /**
   * @param isStoredAsSubDirectories the isStoredAsSubDirectories to set
   */
  public void setStoredAsSubDirectories(boolean isStoredAsSubDirectories) {
    this.isStoredAsSubDirectories = isStoredAsSubDirectories;
  }

  /**
   * @param isDropIfExists the isDropIfExists to set
   */
  public void setDropIfExists(boolean isDropIfExists) {
    this.isDropIfExists = isDropIfExists;
  }

  /**
   * @return isDropIfExists
   */
  public boolean getIsDropIfExists() {
    return isDropIfExists;
  }

  /**
   * @return isCascade
   */
  public boolean getIsCascade() {
    return isCascade;
  }

  /**
   * @param cascade the isCascade to set
   */
  public void setIsCascade(boolean isCascade) {
    this.isCascade = isCascade;
  }

  public static boolean doesAlterTableTypeSupportPartialPartitionSpec(AlterTableTypes type) {
    return alterTableTypesWithPartialSpec.contains(type);
  }

  public EnvironmentContext getEnvironmentContext() {
    return environmentContext;
  }

  public void setEnvironmentContext(EnvironmentContext environmentContext) {
    this.environmentContext = environmentContext;
  }

  /**
   * @return what kind of replication scope this alter is running under.
   * This can result in a "ALTER IF NEWER THAN" kind of semantic
   */
  public ReplicationSpec getReplicationSpec(){ return this.replicationSpec; }

  @Override
  public void setWriteId(long writeId) {
    this.writeId = writeId;
  }

  @Override
  public String getFullTableName() {
    return getOldName();
  }

  @Override
  public boolean mayNeedWriteId() {
    return getOp() == AlterTableDesc.AlterTableTypes.ADDPROPS
        && AcidUtils.isToInsertOnlyTable(null, getProps());
  }

  public Long getWriteId() {
    return this.writeId;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy