title: Find a character index in string in spark sql
body: <p>I am SQL person and new to Spark SQL</p>
  
  <p>I need to find the position of character index '-' is in the string if there is then i need to put the fix length of the character otherwise length zero</p>
  
  <pre><code>string name = 'john-smith'
  </code></pre>
  
  <p>if  '-' is in character position 4 then 10 otherwise length 0</p>
  
  <p>I have done in SQL Server but now need to do in Spark SQL.</p>
  
  <pre><code>select 
  case 
  when charindex('-', name) = 4 then 10
  else 0 
  end 
  </code></pre>
  
  <p>I tried in Spark SQL but failed to get results. </p>
  
  <pre><code>select find_in_set('-',name) 
  </code></pre>
  
  <p>Please help. Thanks</p>