title: Apache spark Row getAs[String] : java.lang.Byte cannot be cast to java.lang.String
body: <p>I have a Spark Dataframe, which looks like this:</p>
  <pre><code>+-----------+-----+
  |foo        |  bar|
  +-----------+-----+
  |          3|10119|
  |          2| 4305|
  +-----------+-----+
  </code></pre>
  <p>And it has the following schema</p>
  <pre class="lang-scala prettyprint-override"><code>org.apache.spark.sql.types.StructType = StructType(
      StructField(foo,ByteType,true), 
      StructField(bar,LongType,false)
  )
  </code></pre>
  <p>As you can see, the column <code>foo</code> is of <code>ByteType</code>.</p>
  <p>I need to get the first row of <code>foo</code> as a String.</p>
  <p>When I try</p>
  <pre class="lang-scala prettyprint-override"><code>val fooStr = df.first.getAs[String](0)
  </code></pre>
  <p>I get cast exception :</p>
  <pre><code>java.lang.ClassCastException: java.lang.Byte cannot be cast to java.lang.String
  </code></pre>
  <p>However when I use <code>toString</code>, I am able to cast</p>
  <pre class="lang-scala prettyprint-override"><code>val myStr = df.first.get(0).toString
  </code></pre>
  <p>Why is it that when I use <code>Row.getAs[String]</code> I get a casting exception , but when I use <code>toString</code>, there is no error. Is there any drawback to using <code>toString</code>?</p>