PartitionPruningRDD is using index from parent

I was getting a ArrayIndexOutOfBoundsException exception after doing  union on pruned RDD. The index it was using on the partition was the index in the original RDD not the new pruned RDD.