@Override
  protected void postProcess(TableName tableName, Table table, AlterTableAddPartitionDesc desc, Task<DDLWork> ddlTask)
      throws SemanticException {
    // Compile internal query to capture underlying table partition dependencies
    String dbTable = HiveUtils.unparseIdentifier(tableName.getDb(), conf) + "." +
        HiveUtils.unparseIdentifier(tableName.getTable(), conf);

    StringBuilder where = new StringBuilder();
    boolean firstOr = true;
    for (AlterTableAddPartitionDesc.PartitionDesc partitionDesc : desc.getPartitions()) {
      if (firstOr) {
        firstOr = false;
      } else {
        where.append(" OR ");
      }
      boolean firstAnd = true;
      where.append("(");
      for (Map.Entry<String, String> entry : partitionDesc.getPartSpec().entrySet()) {
        if (firstAnd) {
          firstAnd = false;
        } else {
          where.append(" AND ");
        }
        where.append(HiveUtils.unparseIdentifier(entry.getKey(), conf));
        where.append(" = '");
        where.append(HiveUtils.escapeString(entry.getValue()));
        where.append("'");
      }
      where.append(")");
    }

    String query = String.format(VIEW_VALIDATE_QUERY, dbTable, where.toString());
    // FIXME: is it ok to have a completely new querystate?
    try (Driver driver = new Driver(QueryState.getNewQueryState(conf, queryState.getLineageState()))) {
      int rc = driver.compile(query, false);
      if (rc != 0) {
        throw new SemanticException(ErrorMsg.NO_VALID_PARTN.getMsg());
      }
      inputs.addAll(driver.getPlan().getInputs());
    }
  }
Analyzer for add partition commands for views.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/partition/add/AlterViewAddPartitionAnalyzer.java