You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/05/22 02:02:55 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #28603: [SPARK-31788][CORE] Fix UnionRDD of PairRDDs

HyukjinKwon commented on a change in pull request #28603:
URL: https://github.com/apache/spark/pull/28603#discussion_r429005432



##########
File path: python/pyspark/context.py
##########
@@ -864,8 +865,20 @@ def union(self, rdds):
         first_jrdd_deserializer = rdds[0]._jrdd_deserializer
         if any(x._jrdd_deserializer != first_jrdd_deserializer for x in rdds):
             rdds = [x._reserialize() for x in rdds]
-        cls = SparkContext._jvm.org.apache.spark.api.java.JavaRDD
-        jrdds = SparkContext._gateway.new_array(cls, len(rdds))
+        gw = SparkContext._gateway
+        jvm = SparkContext._jvm
+        jrdd_cls = jvm.org.apache.spark.api.java.JavaRDD
+        pair_jrdd_cls = jvm.org.apache.spark.api.java.JavaPairRDD
+        double_jrdd_cls = jvm.org.apache.spark.api.java.JavaDoubleRDD
+        if is_instance_of(gw, rdds[0]._jrdd, jrdd_cls):
+            cls = jrdd_cls
+        elif is_instance_of(gw, rdds[0]._jrdd, pair_jrdd_cls):
+            cls = pair_jrdd_cls
+        elif is_instance_of(gw, rdds[0]._jrdd, double_jrdd_cls):
+            cls = double_jrdd_cls
+        else:
+            raise TypeError("Unsupported java rdd class %s", rdds[0]._jrdd)
+        jrdds = gw.new_array(cls, len(rdds))

Review comment:
       Can you check https://github.com/apache/spark/pull/19498? The best way might be just add `lambda x: x` and make it `JavaRDD`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org