title: Scala Spark Sql - Reading null values from a Hive row
body: <p>I have a hive table <code>table_1</code> with the following schema</p>
  
  <pre><code>field_1 string
  field_2 string
  field_3 
    - field_3_1 string
    - field_3_2 double (nullable)
  </code></pre>
  
  <p>When I have an entry with the following values</p>
  
  <pre><code>field_1: "100"
  field_2: "name"
  field_3: 
    - field_3_1: "category_1"
    - field_3_2: null
  </code></pre>
  
  <p>I am trying to read this value from Scala as follows</p>
  
  <pre><code>sparkSession.sql("select field_1, field_3 from table_1 where field_1 ='100'").na
        .fill(new lang.Double(0), Seq("field_3.field_3_2")).foreach { r =&gt;
            println(r)
      }
  </code></pre>
  
  <p>And I keep running into this error</p>
  
  <pre><code>java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Double
  </code></pre>
  
  <p>I don't control how the values get populated in the hive table. I am finding pretty difficult to move past this error even with wide searching of the web. Maybe I missed some clue somewhere. Can someone help with this? Thanks</p>