When I try to split a string by backtick (`) symbol in REPL, it gives me an array of string output and the same was working during run time also with my jar file
Suddenly, the jar file code is not splitting the string by backtick
This backtick is the delimiter and it's being passed as an argument from a shell script
I tried to manually put backtick in split function in the code but below is the error for both cases
val delimiter=args(0) //this argument value is backtick (`),passed from shell during spark-submit command like spark-submit jarfile \`
val FileContent="tablename`dbname`type"
case class ABC(a: String,b: String,c: String)
def parseFile(): ABC= {
val Array(a,b,c) = FileContent.split(delimiter) //this is where its giving below mentioned error, its not splitting by backtick
ABC(a,b,c)
}
val individualRecord = parseFile
Exception in thread "main" scala.MatchError: [Ljava.lang.String;@a4b2d8f (of class [Ljava.lang.String;)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:851)
at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:167)
at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:195)
at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:86)
at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:926)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:935)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
if(delimiter == "`") println("yes") else println("no")
//above prints **yes**
//and below prints **backtick**
delimiter match {
case "`" => println("backtick")
case _ => println("not a backtick")
}