protected void validateAlterTableType(Table table, AlterTableType op, boolean expectView)
      throws SemanticException {
    if (table.isView()) {
      if (!expectView) {
        throw new SemanticException(ErrorMsg.ALTER_COMMAND_FOR_VIEWS.getMsg());
      }

      switch (op) {
      case ADDPARTITION:
      case DROPPARTITION:
      case RENAMEPARTITION:
      case ADDPROPS:
      case DROPPROPS:
      case RENAME:
        // allow this form
        break;
      default:
        throw new SemanticException(ErrorMsg.ALTER_VIEW_DISALLOWED_OP.getMsg(op.toString()));
      }
    } else {
      if (expectView) {
        throw new SemanticException(ErrorMsg.ALTER_COMMAND_FOR_TABLES.getMsg());
      }
    }
    if (table.isNonNative() && table.getStorageHandler() != null &&
        !table.getStorageHandler().isAllowedAlterOperation(op)) {
        throw new SemanticException(ErrorMsg.ALTER_TABLE_NON_NATIVE.format(
            AlterTableType.NON_NATIVE_TABLE_ALLOWED.toString(), table.getTableName()));
    }
  }
Abstract ancestor of all Alter Table analyzer.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/AbstractBaseAlterTableAnalyzer.java