Github user lw-lin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14118#discussion_r73666106
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVTypeCastSuite.scala
 ---
    @@ -68,16 +68,48 @@ class CSVTypeCastSuite extends SparkFunSuite {
       }
     
       test("Nullable types are handled") {
    -    assert(CSVTypeCast.castTo("", IntegerType, nullable = true, 
CSVOptions()) == null)
    +    assertNull(
    +      CSVTypeCast.castTo("-", ByteType, nullable = true, 
CSVOptions("nullValue", "-")))
    +    assertNull(
    +      CSVTypeCast.castTo("-", ShortType, nullable = true, 
CSVOptions("nullValue", "-")))
    +    assertNull(
    +      CSVTypeCast.castTo("-", IntegerType, nullable = true, 
CSVOptions("nullValue", "-")))
    +    assertNull(
    +      CSVTypeCast.castTo("-", LongType, nullable = true, 
CSVOptions("nullValue", "-")))
    +    assertNull(
    +      CSVTypeCast.castTo("-", FloatType, nullable = true, 
CSVOptions("nullValue", "-")))
    +    assertNull(
    +      CSVTypeCast.castTo("-", DoubleType, nullable = true, 
CSVOptions("nullValue", "-")))
    +    assertNull(
    +      CSVTypeCast.castTo("-", BooleanType, nullable = true, 
CSVOptions("nullValue", "-")))
    +    assertNull(
    +      CSVTypeCast.castTo("-", DecimalType.DoubleDecimal, true, 
CSVOptions("nullValue", "-")))
    +    assertNull(
    +      CSVTypeCast.castTo("-", TimestampType, nullable = true, 
CSVOptions("nullValue", "-")))
    +    assertNull(
    +      CSVTypeCast.castTo("-", DateType, nullable = true, 
CSVOptions("nullValue", "-")))
    +    assertNull(
    +      CSVTypeCast.castTo("-", StringType, nullable = true, 
CSVOptions("nullValue", "-")))
       }
     
    -  test("String type should always return the same as the input") {
    +  test("String type should also respect `nullValue`") {
         assert(
           CSVTypeCast.castTo("", StringType, nullable = true, CSVOptions()) ==
    -        UTF8String.fromString(""))
    +        null)
         assert(
           CSVTypeCast.castTo("", StringType, nullable = false, CSVOptions()) ==
             UTF8String.fromString(""))
    +
    +    assert(
    +      CSVTypeCast.castTo("", StringType, nullable = true, 
CSVOptions("nullValue", "null")) ==
    +        UTF8String.fromString(""))
    +    assert(
    +      CSVTypeCast.castTo("", StringType, nullable = false, 
CSVOptions("nullValue", "null")) ==
    +        UTF8String.fromString(""))
    +
    +    assert(
    +      CSVTypeCast.castTo(null, StringType, nullable = true, 
CSVOptions("nullValue", "null")) ==
    +        null)
    --- End diff --
    
    Oh thanks!
    I did this intentionally so that the change is clear to reviewers. Maybe 
let's see what others think and I'm glad to change this when necessary. :)


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