title: Scala Ordinal Method Call Aliasing
body: <p>In Spark SQL we have <code>Row</code> objects which contain a list of records that make up a row (think <code>Seq[Any]</code>). A <code>Row</code>has ordinal accessors such as <code>.getInt(0)</code> or <code>getString(2)</code>. </p>
  
  <p>Say ordinal 0 = ID and ordinal 1 = Name. It becomes hard to remember what ordinal is what, making the code confusing. </p>
  
  <p>Say for example I have the following code</p>
  
  <pre><code>def doStuff(row: Row) = {
    //extract some items from the row into a tuple;
    (row.getInt(0), row.getString(1)) //tuple of ID, Name
  }
  </code></pre>
  
  <p>The question becomes how could I create aliases for these fields in a Row object? </p>
  
  <p>I was thinking I could create methods which take a implicit Row object;</p>
  
  <pre><code>def id(implicit row: Row) = row.getInt(0)
  def name(implicit row: Row) = row.getString(1)
  </code></pre>
  
  <p>I could then rewrite the above as;</p>
  
  <pre><code>def doStuff(implicit row: Row) = {
    //extract some items from the row into a tuple;
    (id, name) //tuple of ID, Name
  }
  </code></pre>
  
  <p>Is there a better/neater approach?</p>