You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by amit kumar singh <am...@gmail.com> on 2019/10/26 11:16:46 UTC
issue with regexp_replace
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 "
Re: issue with regexp_replace
Posted by Aniket Khandelwal <ak...@gmail.com>.
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 <am...@gmail.com>
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 "
>