Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

How to run HQL file in Spark

avatar
New Member

I want to read a hql file in spark job. This hql creates a table by joining 3-4 other tables.

I don't want to write the sql statement in the spark job instead I want to pass HQL file as an argument to spark job and then run the hql file.

Is it possible in Spark ?

1 ACCEPTED SOLUTION

avatar
New Member

We can use below Scala API to read file:

sqlContext.sql(scala.io.Source.fromFile("/vzhome/agaram8/HQLScripts/count.hql").getLines

View solution in original post

8 REPLIES 8

avatar

avatar

@Amit Kumar Agarwal

If you are looking to do it from a program then try something like the below:

http://stackoverflow.com/questions/31313361/sparksql-hql-script-in-file-to-be-loaded-on-python-code

avatar
New Member

This link explains how to execute hive sql using spark-sql shell. But I want to the call the file programatically not through shell.

avatar
New Member

I went through this Stackoverflow link, but I don't see any 'open' API in spark...getting compiler error...

avatar

"open" is not a spark api command, it is a python command. What language are you using? Replace open("file.hql").read() with the equivalent command/code-block in that language.

avatar
New Member

I'm using scala..couldn't find equivalent "open" API in scala.

avatar
New Member

We can use below Scala API to read file:

sqlContext.sql(scala.io.Source.fromFile("/vzhome/agaram8/HQLScripts/count.hql").getLines

avatar
New Member

Hi

Amit Kumar Agarwal

I am looking to run Hive HQL from SPARK SQL.. could you please provide the guidance for same.

Thanks,

Deepesh

deepeshnema@gmail.com