title: string manipulations using Spark scala
body: <p>I have the following Spark scala dataframe.</p>
  
  <pre><code>val someDF = Seq(
    (1, "bat",1.3222),
    (4, "cbat",1.40222),
    (3, "horse",1.501212)
  ).toDF("number", "word","value")
  </code></pre>
  
  <p>I created a User Defined Function (UDF) to create a new variable as follows : </p>
  
  <p>Logic : if words equals bat then value else zero.</p>
  
  <pre><code>  import org.apache.spark.sql.functions.{col}
      val func1 = udf( (s:String ,y:Double) =&gt; if(s.contains("bat")) y else 0 )
      func1(col("word"),col("value"))
  
  +------+-----+-------+
  |number| word|cal_var|
  +------+-----+-------+
  |     1|  bat| 1.3222|
  |     4| cbat|1.40222|
  |     3|horse|    0.0|
  +------+-----+-------+
  </code></pre>
  
  <p>Here to check the equality i used <code>contains</code> function . Because of that i am getting the incorrect output  .
  My desired output should be like this :</p>
  
  <pre><code>+------+-----+-------+
  |number| word|cal_var|
  +------+-----+-------+
  |     1|  bat| 1.3222|
  |     4| cbat|    0.0|
  |     3|horse|    0.0|
  +------+-----+-------+
  </code></pre>
  
  <p>Can anyone help me to figure out the correct string function that i should use to check the equality ? </p>
  
  <p>Thank you </p>