Execute HQL file with beeline command

917 Views Asked by At

i'm trying to execute a query in a test.hql with beeline and i'm not getting results

here the command :

beeline -u "jdbc:hive2://master01:2181,master02:2181,master03:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2" -f test.hql

in test.hql file :

select * from db1.tab1 limit 20;

But if i execute the command with the parameter -e which execute directly the query,it gives me the results

beeline -u "jdbc:hive2://master01:2181,master02:2181,master03:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2" -e "select * from db1.tab1 limit 20;"

Am i missing something ?

1

There are 1 best solutions below

1
Koushik Roy On

You're right. -e is used to execute one or multiple queries and see the result.

-f is mostly used to run scripts like insert into mytab select * from ourtab; where you dont need to see all the rows.

For more options you can check- https://cwiki.apache.org/confluence/display/hive/hiveserver2+clients#HiveServer2Clients-BeelineHiveCommands