title: Extract information from a `org.apache.spark.sql.Row`
body: <p>I have <code>Array[org.apache.spark.sql.Row]</code> returned by <code>sqc.sql(sqlcmd).collect()</code>:</p>
  
  <pre><code>Array([10479,6,10], [8975,149,640], ...)
  </code></pre>
  
  <p>I can get the individual values:</p>
  
  <pre><code>scala&gt; pixels(0)(0)
  res34: Any = 10479
  </code></pre>
  
  <p>but they are <code>Any</code>, not <code>Int</code>.</p>
  
  <p>How do I extract them as <code>Int</code>?</p>
  
  <p><a href="https://spark.apache.org/docs/1.1.0/api/java/org/apache/spark/sql/api/java/Row.html#getInt%28int%29" rel="noreferrer">The most obvious solution</a> did not work:</p>
  
  <pre><code>scala&gt; pixels(0).getInt(0)
  java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Int
  </code></pre>
  
  <p>PS. I can do <code>pixels(0)(0).toString.toInt</code> or <code>pixels(0).getString(0).toInt</code>, but they feel wrong...</p>