protected void validateReplaceWithPartitions(String viewName, Table oldView, List<FieldSchema> partitionColumns)
      throws SemanticException {
    if (oldView.getPartCols().isEmpty() || oldView.getPartCols().equals(partitionColumns)) {
      return;
    }

    String partitionViewErrorMsg = "The following view has partition, it could not be replaced: " + viewName;
    List<Partition> partitions = null;
    GetProjectionsSpec getProjectionsSpec = new GetPartitionProjectionsSpecBuilder()
            .addProjectFieldList(Arrays.asList("values")).build();

    GetPartitionsRequest request = new GetPartitionsRequest(oldView.getDbName(), oldView.getTableName(),
            getProjectionsSpec, null);
    request.setCatName(oldView.getCatName());
    try {
      partitions = db.getPartitionsWithSpecs(oldView, request);
    } catch (HiveException | TException e) {
      throw new SemanticException(ErrorMsg.REPLACE_VIEW_WITH_PARTITION.getMsg(partitionViewErrorMsg));
    }

    if (!partitions.isEmpty()) {
      throw new SemanticException(ErrorMsg.REPLACE_VIEW_WITH_PARTITION.getMsg(partitionViewErrorMsg));
    }
  }
Abstract ancestor of analyzers that can create a view.
ql/src/java/org/apache/hadoop/hive/ql/ddl/view/create/AbstractCreateViewAnalyzer.java