Unable to pass parameter to Spark SQL

Hello All,

I am learning spark and i am facing with one issue state, below:
I have a code like below:

val trigdate=sqlContext.sql(""“SELECT ‘2017-04-02’”"").first.get(0)
val Step1=sqlContext.sql(""“SELECT gmt_dt AS gmt_dt FROM mydb.ivr_events WHERE gmt_dt BETWEEN IBECDateAdd(‘dd’, -1, “””+trigdate+ “”") AND IBECDateAdd(‘dd’, 1, “”"+trigdate+ “”") LIMIT 10""").collect.foreach(println)

Here there is no issue with IBECDateAdd as i have user this UDF since long time, only the problem with parameter passing to sql context. when i execute above statements, i am getting:

org.apache.hadoop.hive.ql.metadata.HiveException: Unable to execute method IBECDateAdd.evaluate(…)…IBECDateAdd with arguments {dd:org.apache.hadoop.io.Text, -1:org.apache.hadoop.io.IntWritable, 2011:org.apache.hadoop.io.Text} of size 3

From the above error, i can see that, though i am passing the complete date that is ‘2017-04-02’, but the function receiving 2011 instead of 2017-04-02, not sure why. Can some one please help me?

Thank you!!

Never Mind, I got the solution, I need to place the “”"+trigdate+ “”" in single codes ’ ', like ‘"""+trigdate+ “”"’.