@Override
    public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx, Object... nodeOutputs)
        throws SemanticException {
      FilterOperator filter = (FilterOperator) nd;
      FilterDesc desc = filter.getConf();

      TableScanOperator ts = (TableScanOperator) stack.get(stack.size() - 2);

      // collect
      CollectContext removalContext = new CollectContext();
      collect(desc.getPredicate(), removalContext);
      CollectContext tsRemovalContext = new CollectContext();
      collect(ts.getConf().getFilterExpr(), tsRemovalContext);

      for (Pair<ExprNodeDesc,ExprNodeDesc> pair : removalContext.dynamicListNodes) {
        ExprNodeDesc child = pair.left;
        ExprNodeDesc columnDesc = child.getChildren().get(0);
        assert child.getChildren().get(1) instanceof ExprNodeDynamicListDesc;
        ExprNodeDesc parent = pair.right;

        String column = ExprNodeDescUtils.extractColName(columnDesc);
        if (column != null) {
          Table table = ts.getConf().getTableMetadata();

          boolean generate = false;
          if (table != null && table.isPartitionKey(column)) {
            generate = true;
            for (ExprNodeDesc filterColumnDesc : removalContext.comparatorNodes) {
              if (columnDesc.isSame(filterColumnDesc)) {
                generate = false;
                break;
              }
            }
          }
          if (!generate) {
            // We can safely remove the condition by replacing it with "true"
            ExprNodeDesc constNode = new ExprNodeConstantDesc(TypeInfoFactory.booleanTypeInfo, Boolean.TRUE);
            if (parent == null) {
              desc.setPredicate(constNode);
            } else {
              int i = parent.getChildren().indexOf(child);
              parent.getChildren().remove(i);
              parent.getChildren().add(i, constNode);
            }
            // We remove it from the TS too if it was pushed
            for (Pair<ExprNodeDesc,ExprNodeDesc> tsPair : tsRemovalContext.dynamicListNodes) {
              ExprNodeDesc tsChild = tsPair.left;
              ExprNodeDesc tsParent = tsPair.right;
              if (tsChild.isSame(child)) {
                if (tsParent == null) {
                  ts.getConf().setFilterExpr(null);
                } else {
                  int i = tsParent.getChildren().indexOf(tsChild);
                  if (i != -1) {
                    tsParent.getChildren().remove(i);
                    tsParent.getChildren().add(i, constNode);
                  }
                }
                break;
              }
            }
            LOG.info("Dynamic pruning condition removed: " + child);
          }
        }
      }
      return false;
    }
Transform the query tree.

@param pctx the current parse context
ql/src/java/org/apache/hadoop/hive/ql/optimizer/RedundantDynamicPruningConditionsRemoval.java