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 2021/07/20 14:50:42 UTC

[GitHub] [spark] sammyjmoseley commented on a change in pull request #33364: [SPARK-36161][PYTHON] Add type check on dropDuplicates pyspark function

sammyjmoseley commented on a change in pull request #33364:
URL: https://github.com/apache/spark/pull/33364#discussion_r673196070



##########
File path: python/pyspark/sql/tests/test_dataframe.py
##########
@@ -67,6 +67,35 @@ def test_help_command(self):
         pydoc.render_doc(df.foo)
         pydoc.render_doc(df.take(1))
 
+    # SPARK-36034 test that drop duplicates throws a type error when in correct type provided
+    def test_drop_duplicates(self):
+        schema = StructType([
+            StructField("name", StringType(), True),
+            StructField("age", IntegerType(), True)]
+        )
+
+        # shouldn't drop a non-null row
+        self.assertEqual(self.spark.createDataFrame(
+            [(u'Alice', 50), (u'Alice', 60)], schema).dropDuplicates().count(),
+            2)
+
+        self.assertEqual(self.spark.createDataFrame(
+            [(u'Alice', 50), (u'Alice', 60)], schema).dropDuplicates("name").count(),
+            1)
+
+        self.assertEqual(self.spark.createDataFrame(
+            [(u'Alice', 50), (u'Alice', 60)], schema).dropDuplicates(["name"]).count(),
+            1)
+
+        self.assertEqual(self.spark.createDataFrame(
+            [(u'Alice', 50), (u'Alice', 60)], schema).dropDuplicates(["name", "age"]).count(),
+            2)
+
+        with self.assertRaises(TypeError):
+            self.spark.createDataFrame(
+                [(u'Alice', 50), (u'Alice', 60)], schema
+            ).dropDuplicates("name", "age").count()

Review comment:
       yep, changed!




-- 
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-unsubscribe@spark.apache.org

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