Github user rberenguel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18164#discussion_r119798778
  
    --- Diff: python/pyspark/sql/tests.py ---
    @@ -1697,40 +1697,56 @@ def test_fillna(self):
             schema = StructType([
                 StructField("name", StringType(), True),
                 StructField("age", IntegerType(), True),
    -            StructField("height", DoubleType(), True)])
    +            StructField("height", DoubleType(), True),
    +            StructField("spy", BooleanType(), True)])
     
             # fillna shouldn't change non-null values
    -        row = self.spark.createDataFrame([(u'Alice', 10, 80.1)], 
schema).fillna(50).first()
    +        row = self.spark.createDataFrame([(u'Alice', 10, 80.1, True)], 
schema).fillna(50).first()
             self.assertEqual(row.age, 10)
     
             # fillna with int
    -        row = self.spark.createDataFrame([(u'Alice', None, None)], 
schema).fillna(50).first()
    +        row = self.spark.createDataFrame([(u'Alice', None, None, None)], 
schema).fillna(50).first()
             self.assertEqual(row.age, 50)
             self.assertEqual(row.height, 50.0)
     
             # fillna with double
    -        row = self.spark.createDataFrame([(u'Alice', None, None)], 
schema).fillna(50.1).first()
    +        row = self.spark.createDataFrame([(u'Alice', None, None, None)], 
schema).fillna(50.1).first()
             self.assertEqual(row.age, 50)
             self.assertEqual(row.height, 50.1)
     
    +        # fillna with bool
    +        row = self.spark.createDataFrame([(u'Alice', None, None, None)], 
schema).fillna(True).first()
    +        self.assertEqual(row.age, None)
    +        self.assertEqual(row.spy, True)
    +
             # fillna with string
    -        row = self.spark.createDataFrame([(None, None, None)], 
schema).fillna("hello").first()
    +        row = self.spark.createDataFrame([(None, None, None, None)], 
schema).fillna("hello").first()
             self.assertEqual(row.name, u"hello")
             self.assertEqual(row.age, None)
     
             # fillna with subset specified for numeric cols
             row = self.spark.createDataFrame(
    -            [(None, None, None)], schema).fillna(50, subset=['name', 
'age']).first()
    +            [(None, None, None, None)], schema).fillna(50, subset=['name', 
'age']).first()
             self.assertEqual(row.name, None)
             self.assertEqual(row.age, 50)
             self.assertEqual(row.height, None)
    +        self.assertEqual(row.spy, None)
     
    -        # fillna with subset specified for numeric cols
    +        # fillna with subset specified for string cols
             row = self.spark.createDataFrame(
    -            [(None, None, None)], schema).fillna("haha", subset=['name', 
'age']).first()
    +            [(None, None, None, None)], schema).fillna("haha", 
subset=['name', 'age']).first()
             self.assertEqual(row.name, "haha")
             self.assertEqual(row.age, None)
             self.assertEqual(row.height, None)
    +        self.assertEqual(row.spy, None)
    +
    +        # fillna with subset specified for bool cols
    +        row = self.spark.createDataFrame(
    +            [(None, None, None, None)], schema).fillna(True, 
subset=['name', 'age']).first()
    +        self.assertEqual(row.name, None)
    +        self.assertEqual(row.age, None)
    +        self.assertEqual(row.height, None)
    +        self.assertEqual(row.spy, True)
    --- End diff --
    
    Hi @ueshin indeed! Thanks for catching this, I have modified the test. BUT, 
this test, as it stands on your comment, should have failed, doesn't it? The 
subset should not have been applied to spy (so, spy should have been None, and 
the assertion should have been marked as false, but either the test passed or 
the test didn't run), if I understood correctly how subsetting fillna's work. 
But this is weird, since I didn't change any internals of how it works, I just 
created the methods to enable it. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to