I have code like so with a multiline query
val hiveInsertIntoTable = spark.read.text(fileQuery).collect()
hiveInsertIntoTable.foreach(println)
val actualQuery = hiveInsertIntoTable(0).mkString
println(actualQuery)
spark.sql(s"truncate table $tableTruncate")
spark.sql(actualQuery)
Whenever I try to execute actual query I get an error.
org.apache.spark.sql.catalyst.parser.ParseException:
no viable alternative at input '<EOF>'(line 1, pos 52)
== SQL ==
insert into wera_tacotv_esd.lac_asset_table_pb_hive
----------------------------------------------------^^^
and the end of the query .... ; (terminates in a ;)
The query is actually about 450 lines
I tried to wrap the variable in triple quotes but that didn't work either.
Any help is appreciated.
I am using spark 2.1 and scala 2.11