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



##########
File path: python/pyspark/pandas/indexes/base.py
##########
@@ -2292,9 +2292,7 @@ def union(
 
         sdf_self = 
self._internal.spark_frame.select(self._internal.index_spark_columns)
         sdf_other = 
other_idx._internal.spark_frame.select(other_idx._internal.index_spark_columns)
-        sdf = sdf_self.union(sdf_other.subtract(sdf_self))
-        if isinstance(self, MultiIndex):
-            sdf = sdf.drop_duplicates()
+        sdf = 
sdf_self.unionAll(sdf_other).exceptAll(sdf_self.intersectAll(sdf_other))
         if sort:

Review comment:
       @itholic, did you refer to this?
   
   > Bug in Index.union() and MultiIndex.union() dropping duplicate Index 
values when Index was not monotonic or sort was set to False (GH36289, GH31326, 
GH40862)
   
   It sounds like now it drops duplicates but the codes above in Pr description 
look keeping the duplicates. Should we also at least check `sort` and drop 
duplicates?




-- 
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.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

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



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

Reply via email to