Github user mridulm commented on a diff in the pull request: https://github.com/apache/spark/pull/22010#discussion_r217876215 --- Diff: core/src/main/scala/org/apache/spark/rdd/RDD.scala --- @@ -396,7 +396,26 @@ abstract class RDD[T: ClassTag]( * Return a new RDD containing the distinct elements in this RDD. */ def distinct(numPartitions: Int)(implicit ord: Ordering[T] = null): RDD[T] = withScope { - map(x => (x, null)).reduceByKey((x, y) => x, numPartitions).map(_._1) + partitioner match { + case Some(p) if numPartitions == partitions.length => + def key(x: T): (T, Null) = (x, null) + val cleanKey = sc.clean(key _) + val keyed = new MapPartitionsRDD[(T, Null), T]( + this, + (context, pid, iter) => iter.map(cleanKey), + knownPartitioner = Some(new WrappedPartitioner(p))) + val duplicatesRemoved = keyed.reduceByKey((x, y) => x) --- End diff -- Dont you need to specify the partitioner here ?
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org