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

    https://github.com/apache/spark/pull/18820#discussion_r132104291
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/DataFrameNaFunctionsSuite.scala ---
    @@ -261,5 +261,37 @@ class DataFrameNaFunctionsSuite extends QueryTest with 
SharedSQLContext {
         assert(out1(3).get(2).asInstanceOf[Double].isNaN)
         assert(out1(4) === Row("Amy", null, null))
         assert(out1(5) === Row(null, null, null))
    +
    +    // Replace String with String and null
    +    val out2 = input.na.replace("name", Map(
    +      "Bob" -> "Bravo",
    +      "Alice" -> null
    +    )).collect()
    +
    +    assert(out2(0) === Row("Bravo", 16, 176.5))
    +    assert(out2(1) === Row(null, null, 164.3))
    +    assert(out2(2) === Row("David", 60, null))
    +    assert(out2(3).get(2).asInstanceOf[Double].isNaN)
    +    assert(out2(4) === Row("Amy", null, null))
    +    assert(out2(5) === Row(null, null, null))
    +
    +    // Replace Double with null
    +    val out3 = input.na.replace("age", Map[Any, Any](
    +      16 -> null
    +    )).collect()
    +
    +    assert(out3(0) === Row("Bob", null, 176.5))
    +    assert(out3(1) === Row("Alice", null, 164.3))
    +    assert(out3(2) === Row("David", 60, null))
    +    assert(out3(3).get(2).asInstanceOf[Double].isNaN)
    +    assert(out3(4) === Row("Amy", null, null))
    +    assert(out3(5) === Row(null, null, null))
    +
    +    // Replace String with null and then drop rows containing null
    +    checkAnswer(
    +      input.na.replace("name", Map(
    +        "Bob" -> null
    +      )).na.drop("name" :: Nil).select("name"),
    +      Row("Alice") :: Row("David") :: Row("Nina") :: Row("Amy") :: Nil)
    --- End diff --
    
    Also add a test case for boolean


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