public Partition loadPartition(Path loadPath, Table tbl, Map<String, String> partSpec,
                                 LoadFileType loadFileType, boolean inheritTableSpecs,
                                 boolean inheritLocation,
                                 boolean isSkewedStoreAsSubdir,
                                 boolean isSrcLocal, boolean isAcidIUDoperation,
                                 boolean resetStatistics, Long writeId,
                                 int stmtId, boolean isInsertOverwrite, boolean isDirectInsert) throws HiveException {

    PerfLogger perfLogger = SessionState.getPerfLogger();
    perfLogger.perfLogBegin("MoveTask", PerfLogger.LOAD_PARTITION);

    // Get the partition object if it already exists
    Partition oldPart = getPartition(tbl, partSpec, false);
    boolean isTxnTable = AcidUtils.isTransactionalTable(tbl);

    // If config is set, table is not temporary and partition being inserted exists, capture
    // the list of files added. For not yet existing partitions (insert overwrite to new partition
    // or dynamic partition inserts), the add partition event will capture the list of files added.
    List<FileStatus> newFiles = null;
    if (conf.getBoolVar(ConfVars.FIRE_EVENTS_FOR_DML) && !tbl.isTemporary()) {
      newFiles = Collections.synchronizedList(new ArrayList<>());
    }

    Partition newTPart = loadPartitionInternal(loadPath, tbl, partSpec, oldPart,
            loadFileType, inheritTableSpecs,
            inheritLocation, isSkewedStoreAsSubdir, isSrcLocal, isAcidIUDoperation,
            resetStatistics, writeId, stmtId, isInsertOverwrite, isTxnTable, newFiles, isDirectInsert);

    AcidUtils.TableSnapshot tableSnapshot = isTxnTable ? getTableSnapshot(tbl, writeId) : null;
    if (tableSnapshot != null) {
      newTPart.getTPartition().setWriteId(tableSnapshot.getWriteId());
    }

    if (oldPart == null) {
      addPartitionToMetastore(newTPart, resetStatistics, tbl, tableSnapshot);
      // For acid table, add the acid_write event with file list at the time of load itself. But
      // it should be done after partition is created.
      if (isTxnTable && (null != newFiles)) {
        addWriteNotificationLog(tbl, partSpec, newFiles, writeId, null);
      }
    } else {
      try {
        setStatsPropAndAlterPartition(resetStatistics, tbl, newTPart, tableSnapshot);
      } catch (TException e) {
        LOG.error("Error loading partitions", e);
        throw new HiveException(e);
      }
    }

    perfLogger.perfLogEnd("MoveTask", PerfLogger.LOAD_PARTITION);

    return newTPart;
  }
Load a directory into a Hive Table Partition - Alters existing content of
the partition with the contents of loadPath. - If the partition does not
exist - one is created - files in loadPath are moved into Hive. But the
directory itself is not removed.

@param loadPath
         Directory containing files to load into Table
@param  tbl
         name of table to be loaded.
@param partSpec
         defines which partition needs to be loaded
@param loadFileType
         if REPLACE_ALL - replace files in the table,
         otherwise add files to table (KEEP_EXISTING, OVERWRITE_EXISTING)
@param inheritTableSpecs if true, on [re]creating the partition, take the
         location/inputformat/outputformat/serde details from table spec
@param isSrcLocal
         If the source directory is LOCAL
@param isAcidIUDoperation
         true if this is an ACID operation Insert/Update/Delete operation
@param resetStatistics
         if true, reset the statistics. If false, do not reset statistics.
@param writeId write ID allocated for the current load operation
@param stmtId statement ID of the current load statement
@param isInsertOverwrite
@return Partition object being loaded with data
ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java