title: How to get DynamicRecord field value, use that for matching, then update DynamicRecord
body: <p>New to Scala with AWS Glue. What I'm trying to do is to get a value for a field on the DynamicRecord coming in so I can use that to match with, then update the record, then return it.</p>
  <p>In the code below, I'd like to first get the field value with this: <code>rec =&gt; rec.getField(col)</code></p>
  <p>So I can test the value prior to going on to match.</p>
  <p>Here's what I have currently and it works as is.</p>
  <pre><code>    def doSomething(col: String): DynamicRecord =&gt; DynamicRecord = 
      { 
       
        rec =&gt; rec.getField(col) match 
        {
          case Some(s: String) =&gt; 
          {
             //do something with s to the record (rec)
          }
          case default =&gt; do something with default case to the record (rec)
        }
        rec
      }
  </code></pre>
  <p>Note since I'm directly doing the match with <code>rec</code> then I have it available to further update it.</p>
  <p>But I need to get the value first then match and finally return the changed record. Something akin to this below. But because I'm using the field value for the matching, I no longer have reference to the <code>rec</code> inside the case.</p>
  <pre><code>    def doSomething(col: String): DynamicRecord =&gt; DynamicRecord = 
      { 
        var fldVal: String = &quot;&quot;
        rec =&gt; fldVal = rec.getField(col)
  
        fldVal match 
        {
          case Some(s: String) =&gt; 
          {
             //do something to the record with s
          }
          case default =&gt; //do something to the record with default case
        }
        rec //need to return record here
      }
  </code></pre>
  <p>How can I get the field value from rec first then have a reference to rec so I can change it and return it?</p>
  <p>Errors I've received are, missing parameter type, type mismatch.</p>
  <p>Any help appreciated.</p>
  <p>Thanks!</p>