title: How to convert a simple DataFrame to a DataSet Spark Scala with case class?
body: <p>I am trying to convert a simple DataFrame to a DataSet from the example in Spark: 
  <a href="https://spark.apache.org/docs/latest/sql-programming-guide.html" rel="nofollow noreferrer">https://spark.apache.org/docs/latest/sql-programming-guide.html</a></p>
  
  <pre><code>case class Person(name: String, age: Int)    
  import spark.implicits._
  
  val path = "examples/src/main/resources/people.json"
  
  val peopleDS = spark.read.json(path).as[Person]
  peopleDS.show()
  </code></pre>
  
  <p>But the following problem arises:</p>
  
  <pre class="lang-none prettyprint-override"><code>Exception in thread "main" org.apache.spark.sql.AnalysisException: Cannot up cast `age` from bigint to int as it may truncate
  The type path of the target object is:
  - field (class: "scala.Int", name: "age")
  - root class: ....
  </code></pre>
  
  <p>Can anyone help me out?</p>
  
  <p>Edit
  I noticed that with Long instead of Int works!
  Why is that?</p>
  
  <p>Also:</p>
  
  <pre><code>val primitiveDS = Seq(1,2,3).toDS()
  val augmentedDS = primitiveDS.map(i =&gt; ("var_" + i.toString, (i + 1).toLong))
  augmentedDS.show()
  
  augmentedDS.as[Person].show()
  </code></pre>
  
  <p>Prints: </p>
  
  <pre class="lang-none prettyprint-override"><code>+-----+---+
  |   _1| _2|
  +-----+---+
  |var_1|  2|
  |var_2|  3|
  |var_3|  4|
  +-----+---+
  
  Exception in thread "main"
  org.apache.spark.sql.AnalysisException: cannot resolve '`name`' given input columns: [_1, _2];
  </code></pre>
  
  <p>Can Anyone Help me out understand here?</p>