public Integer getStatementIdForAcidWriteType(long writeId, String moveTaskId, AcidUtils.Operation acidOperation, Path path,
                                                int originalStatementId) {
    FileSinkDesc result = null;
    for (FileSinkDesc acidSink : acidSinks) {
      if (acidOperation.equals(acidSink.getAcidOperation()) && path.equals(acidSink.getDestPath())
          && acidSink.getTableWriteId() == writeId
          && (moveTaskId == null || acidSink.getMoveTaskId() == null || moveTaskId.equals(acidSink.getMoveTaskId()))) {
        if (result != null) {
          return -1;
        }
        result = acidSink;
      }
    }
    if (result != null) {
      return result.getStatementId();
    } else {
      // If there were no matching acid sinks proceed with the original statement id. This can happen, if we used the
      // load data inpath command on an insert only table.
      return originalStatementId;
    }
  }
This method is to get the proper statementId for the FileSinkOperator, a particular MoveTask belongs to.
This is needed for ACID operations with direct insert on. In this case for listing the newly added or modified
data the MoveTask has to know the statementId in order to list the files from the proper folder.
Without knowing the statementId the files could be listed by multiple MoveTasks which could cause issues.
To get the statementId, first the FSO has to be found in the acidSinks list. To do that, use
the ACID operation, the path, the writeId and the moveTaskId.

For queries with union all optimisation, there will be multiple FSOs with the same operation, writeId and moveTaskId.
But one of these FSOs doesn't write data and its statementId is not valid, so if this FSO is selected and its statementId
is returned, the file listing will find nothing. So check the acidSinks and if two of them have the same writeId, path
and moveTaskId, then return -1 as statementId. With doing this, the file listing will find all partitions and files correctly.

@param writeId
@param moveTaskId
@param acidOperation
@param path
@return The statementId from the FileSinkOperator with the given writeId, moveTaskId, operation and path.
-1 if there are multiple FileSinkOperators with the same value of these parameters.
The original statement id if there were no matching acid sinks.
ql/src/java/org/apache/hadoop/hive/ql/QueryPlan.java