title: use length function in substring in spark
body: <p>I am trying to use the length function inside a substring function in a <code>DataFrame</code>
  but it gives error </p>
  
  
  
  <pre><code>val substrDF = testDF.withColumn("newcol", substring($"col", 1, length($"col")-1))
  </code></pre>
  
  <p>below is the error</p>
  
  <pre><code> error: type mismatch;
   found   : org.apache.spark.sql.Column
   required: Int
  </code></pre>
  
  <p>I am using 2.1.</p>