issue with regexp_replace

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

issue with regexp_replace

amit kumar singh
Hi Team,


I am trying to use regexp_replace in spark sql  it throwing error 

expected <block end>, but found Scalar
 in 'reader', line 9, column 45:
     ... select translate(payload, '\\\\"', '"') as payload


i am trying to remove all character  from \\\"  with " 
Reply | Threaded
Open this post in threaded view
|

Re: issue with regexp_replace

Aniket Khandelwal
Hi Amit,

I am able to run this test without any issue.
test("string translate with escape characters") {
val df = Seq(("ab\\\"ab", "")).toDF("a", "b")
checkAnswer(df.select(translate($"a", "\\\"", "\"")), Row("ab\"ab"))
checkAnswer(df.selectExpr("""translate(a, "\\\"", "\"")"""), Row("ab\"ab"))
df.createOrReplaceTempView("table")
checkAnswer(spark.sql("select translate(a,'\\\\\"','\"') from table "), Row("ab\"ab"))
}
This is basically converting value ab\\\"ab with ab\"ab.
I need the exact query where you are facing the issue. Might help in debug more.
Dp point out if i am mistaken.

Thanks

On Sat, Oct 26, 2019 at 4:47 PM amit kumar singh <[hidden email]> wrote:
Hi Team,


I am trying to use regexp_replace in spark sql  it throwing error 

expected <block end>, but found Scalar
 in 'reader', line 9, column 45:
     ... select translate(payload, '\\\\"', '"') as payload


i am trying to remove all character  from \\\"  with "