title: Enforcing Schema using .as[A] doesn't enforce the type
body: <p>I'm trying to read a table in SQL Server, and then I want to enforce the schema of what I read. So I defined:</p>
  
  <p><code>case class WhatIWant(FieldA: String, FieldB: String)</code></p>
  
  <p>Then I try to do a regular spark read from SQL server, the Dataframe I read back, is with type of: </p>
  
  <pre><code>input:org.apache.spark.sql.DataFrame
      FieldA:integer
      FieldB:String
  </code></pre>
  
  <p>then I appended <code>.as[WhatIWant]</code> when I read, I thought this would make it a <code>Dataset[WhatIWant]</code> with the typing information as I defined. Turns out, in the notebook, it will actually give me:</p>
  
  <pre><code>intput:org.apache.spark.sql.Dataset[WhatIWant]
      FieldA:integer
      FieldB:String
  </code></pre>
  
  <p>Now I'm confused on two things:</p>
  
  <ol>
  <li>Will <code>.as[]</code> actually enforce the schema if the schema inferred in Dataframe is different than the definition of the case class?</li>
  <li>I was under the assumption Dataset is strongly typed. But the typing info I got from the Databricks notebook is actually not the same as what I defined. Is there an explanation of this?</li>
  </ol>
  
  <p>Quick note:
  All the values for "FieldA" are nulls, I felt like that played a part in this, but I'm still confused.</p>