Reputation: 11
Consider there are few hive queries in a file, my moto is to run the file using hivecontext
or sparkcontext
Using command line I can do that by hive -f 'filepath/filename'
But I have to run it via code (hivecontext
or sparkcontext
)
Can anybody help on this?
For a single query I can use:
sparkContext.SQL('query')
But I have to run a file which is having queries.
Upvotes: 0
Views: 1711
Reputation: 502
You can run your hql file some where like the below :
val Test = sqlContext.sql(open("file.hql").read())
Upvotes: 0
Reputation: 1
You can do it using Spark/Scala:
queryFile = "path_of_your_file_queries"
Source.fromFile(queryFile, "utf-8").getLines().foreach(query => sparksql.sql(query))
Upvotes: 0