HyukjinKwon commented on a change in pull request #33364: URL: https://github.com/apache/spark/pull/33364#discussion_r677307453
########## File path: python/pyspark/sql/tests/test_dataframe.py ########## @@ -67,6 +67,32 @@ def test_help_command(self): pydoc.render_doc(df.foo) pydoc.render_doc(df.take(1)) + def test_drop_duplicates(self): + # SPARK-36034 test that drop duplicates throws a type error when in correct type provided + 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", "age"]).count(), + 2) + + type_error_msg = "Parameter 'subset' must be a list of columns" + with self.assertRaisesRegex(TypeError, type_error_msg): + self.spark.createDataFrame( + [(u'Alice', 50), (u'Alice', 60)], schema + ).dropDuplicates("name").count() Review comment: ```suggestion ).dropDuplicates("name") ``` -- 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