-1

I would like to execute a set of hiveQL statements in my spark driver code, something like below

var res = hiveContext.sql("""use testdb;drop table temp;select ...")

When i executed this code, it gave me an error saying

Error: missing EOF near testdb

Can someone point to me where I am going wrong? Is it really possible to execute more than one statement using the approach above?

Further, i tried putting all my statements in a file "test.hql", and used the below code snippet.

sqlContext.sql(scala.io.Source.fromFile("mytest.hql").mkString)    

Still got the same error as above.

Any thoughts?

0

1 Answer 1

-1

You can put all your queries on file and use this code to execute queries

queryFile = "path_of_your_file_queries"
Source.fromFile(queryFile, "utf-8").getLines().foreach(query => sparksql.sql(query))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.