private List<Partition> addPartitionsToTempTable(List<Partition> partitions, String dbName, String tableName,
      boolean ifNotExists) throws MetaException, AlreadyExistsException {
    if (!validatePartitions(partitions, dbName, tableName)) {
      return null;
    }
    if (dbName == null) {
      dbName = partitions.get(0).getDbName();
    }
    if (tableName == null) {
      tableName = partitions.get(0).getTableName();
    }
    org.apache.hadoop.hive.metastore.api.Table table = getTempTable(dbName, tableName);
    TempTable tt = getPartitionedTempTable(table);
    if (tt == null) {
      throw new IllegalStateException("TempTable not found for " + getCatalogQualifiedTableName(table));
    }
    List<Partition> result = tt.addPartitions(deepCopyPartitions(partitions), ifNotExists);
    for (Partition p : result) {
      createAndSetLocationForAddedPartition(p, getPartitionLocation(table, p, false));
    }
    return result;
  }
Try to add the partitions to an already existing temporary table.

@param partitions  The partitions to add. It must contain at least one item.
@param dbName Name of the database, can be null
@param tableName Name of the table, can be null
@param ifNotExists only add partition if they don't exist
@return the partitions that were added to the temp table. If the temp table is not found, null.
@throws MetaException
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java