Reply
Expert Contributor
Posts: 109
Registered: ‎05-19-2016
Accepted Solution

How to run all of hive queries in a file in one go

I have around 15 queries saved in a saved file in hive editor that is integrated in hue. The queries include CREATE TABLE/DROP TABLE and SELECT statement at the end of the file.

It seems like I can not execute all of these in one go.

 

How do I syntactically format or write hive queries so that hive can understand that we have the next query starting after end of one query .It should then finally give results of the select query.

Cloudera Employee
Posts: 824
Registered: ‎03-23-2015

Re: How to run all of hive queries in a file in one go

Hi sim6,

 

Do you mean that you want to run all the qureries in the file through Hue's Hive Editor interface, rather than running through beeline or Hive CLI?

 

Can you please copy and paste the content of the script here for me to have a look?

 

What was the result you get when you tried to run this file in Hue? You mentioned you can't execute all of them, do you know which ones were executed? And how did you run this file through Hue?

Highlighted
Cloudera Employee
Posts: 34
Registered: ‎08-16-2016

Re: How to run all of hive queries in a file in one go

If this is from HUE, hue can execute multiple command in a sequence until it reaches the first query that returns results (like a select query). For example, the following should be executed entirely in a single go.

 

drop table if exists foo;
create table if not exists foo (code string, description string, salary int);
insert into foo select code, description, salary from sample s where s.salary > 50000 and s.salary < 100000;
select * from foo where salary < 75000;

 

The following will stop after the select query, so the drop table will not be executed.

drop table if exists foo;
create table if not exists foo (code string, description string, salary int);
insert into foo select code, description, salary from sample_07 s where s.salary > 50000 and s.salary < 100000;
select * from foo where salary < 75000;

drop table foo;

 

But if you use beeline to execute a file containing multiple select queries, this should work without pausing.