title: Spark Dataframe sql in java - How to escape single quote
body: <p>I'm using spark-core, spark-sql, Spark-hive 2.10(1.6.1), scala-reflect 2.11.2. I'm trying to filter a dataframe created through hive context...</p>
  
  <pre><code>df = hiveCtx.createDataFrame(someRDDRow,
                      someDF.schema());
  </code></pre>
  
  <p>One of the column that I'm trying to filter has multiple single quotes in it. My filter query will be something similar to</p>
  
  <pre><code>df = df.filter("not (someOtherColumn= 'someOtherValue' and comment= 'That's Dany's Reply'"));
  </code></pre>
  
  <p>In my java class where this filter occurs, I tried to replace the String variable  for e.g commentValueToFilterOut, which contains the value "That's Dany's Reply" with </p>
  
  <pre><code>commentValueToFilterOut= commentValueToFilterOut.replaceAll("'","\\\\'");
  </code></pre>
  
  <p>But when apply the filter to the dataframe I'm getting the below error...</p>
  
  <pre><code>java.lang.RuntimeException: [1.103] failure: ``)'' expected but identifier
  s found
  
      not (someOtherColumn= 'someOtherValue' and comment=  'That\'s Dany\'s Reply'' )
                                                                  ^                                          
      scala.sys.package$.error(package.scala:27)
      org.apache.spark.sql.catalyst.SqlParser$.parseExpression(SqlParser.scala:49)
      org.apache.spark.sql.DataFrame.filter(DataFrame.scala:768) 
  </code></pre>
  
  <p>Please advise...</p>