Created on 08-26-2016 05:55 AM - edited 09-16-2022 03:36 AM
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.
Created 09-02-2016 10:51 AM
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.
Created 08-27-2016 12:33 AM
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?
Created 09-02-2016 10:51 AM
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.