sree
sree

Reputation: 1960

Saving hive queries

I need to know how we can store a query I have written in a command line just like we do in sql(we use ctrl+S in sql server).

I heared hive QL queries use .q or .hql extension.Is there any possibility I save my query to get the same by saving list of commands I am executing.

Upvotes: 2

Views: 3822

Answers (3)

bgt
bgt

Reputation: 19

Create a new file using "cat" command(You can even use editor).Write all the queries you want to perform inside the file

$cat > MyQueries.hql
query1
query2
.
.
Ctrl+D

Note: .hql or .q is not necessary. It is just for our reference to identify that it is a hive query(file).

You can execute all the queries inside the file at a time using

$hive -f MyQueries.hql

Upvotes: 1

Dhruv Kapatel
Dhruv Kapatel

Reputation: 893

You can use hue or web interface to access hive instead of terminal. It will provide you UI from where you can write and execute queries. Solves copy problem too.

http://gethue.com/

https://cwiki.apache.org/confluence/display/Hive/HiveWebInterface

Upvotes: 0

Roshini
Roshini

Reputation: 723

sure whatever ide you use you can just save your file as myfile.q and then run it from the command line as

hive -f myfile.q 

You can also do

hive -f myfile.q > myfileResults.log

if you want to pipe your results into a log file.

Upvotes: 4

Related Questions