private void prunePartitions() throws HiveException {
    int expectedEvents = 0;
    List<ExprNodeDesc> prunerExprs = new LinkedList<>();
    for (Map.Entry<String, List<SourceInfo>> entry : this.sourceInfoMap.entrySet()) {
      String source = entry.getKey();
      for (SourceInfo si : entry.getValue()) {
        int taskNum = context.getVertexNumTasks(source);
        LOG.info("Expecting {} events for vertex {}, for column {}", taskNum, source, si.columnName);
        expectedEvents += taskNum;
        ExprNodeDesc prunerExpr = prunePartitionSingleSource(jobConf, source, si);
        if (prunerExpr != null) {
          prunerExprs.add(prunerExpr);
        }
      }
    }

    // If we have partition pruner expressions to push down then create the appropriate predicate
    if (prunerExprs.size() != 0) {
      ExprNodeGenericFuncDesc prunerExpr;
      if (prunerExprs.size() == 1) {
        prunerExpr = (ExprNodeGenericFuncDesc)prunerExprs.iterator().next();
      } else {
        // If we have multiple pruner expressions wrap them into an AND
        prunerExpr = new ExprNodeGenericFuncDesc(TypeInfoFactory.booleanTypeInfo, new GenericUDFOPAnd(), "and", prunerExprs);
      }

      // Push the predicate to the config for further use in HiveInputFormat
      jobConf.set(TableScanDesc.PARTITION_PRUNING_FILTER, SerializationUtilities.serializeExpression(prunerExpr));
    }

    // sanity check. all tasks must submit events for us to succeed.
    if (expectedEvents != totalEventCount) {
      LOG.error("Expecting: {} events, received: {}", expectedEvents, totalEventCount);
      throw new HiveException("Incorrect event count in dynamic partition pruning");
    }
  }
DynamicPartitionPruner takes a list of assigned partitions at runtime (split
generation) and prunes them using events generated during execution of the
dag.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DynamicPartitionPruner.java