How to pass multiple sql files in impala command line

Viewed 414

I have multiple .sql files like (1.sql, 2.sql, 3.sql) and it contains the following queries.

1.sql:

show databases;

2.sql:

use default;

3.sql:

show tables;

4.sql:

select count(*) from employee limit 5;

I am trying to pass the files as mentioned below.

impala-shell -f 1.sql; 2.sql; 3.sql; 4.sql

In this case the command is executing only 1.sql and exiting from the terminal stating that 2.sql .. command not found.

I know I can put all the above queries in a single .sql file, but my question is how to pass multiple .sql files via command line.

Can someone suggest me how can I pass multiple .sql files to impala from command line?

2 Answers

It may be quite simple if you have Impala version 2.3 or higher, because then you can substitute query file for stdin. So something like that should work:

$ cat 1.sql 2.sql 3.sql | impala-shell -i "impala-host:port" -f -

(mind the last dash -)

I tried to put 2 sql file in the same way but what it does is just read the file but not execute these 2 files inside impala shell and version currently I am using is 3.2

Related