Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-17763

JacksonParser silently parses null as 0 when the field is not nullable

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Incomplete
    • None
    • None
    • SQL

    Description

      It seems JacksonParser parses the json when the field is not nullable, it parses some data as 0 silently. For example,

      val testJson = """{"nullInt":null}""" :: Nil
      val testSchema = StructType(StructField("nullInt", IntegerType, false) :: Nil)
      val data = spark.sparkContext.parallelize(testJson)
      spark.read.schema(testSchema).json(data).show()
      

      shows

      +-------+
      |nullInt|
      +-------+
      |      0|
      +-------+
      

      This will also affect from_json function.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gurwls223 Hyukjin Kwon
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: