Using the Impala Shell (impala-shell Command)

You can use the Impala shell tool (impala-shell) to set up databases and tables, insert
data, and issue queries. For ad hoc queries and exploration, you can submit SQL statements in an interactive
session. To automate your work, you can specify command-line options to process a single statement or a
script file. The impala-shell interpreter accepts all the same SQL statements listed in
Impala SQL Statements, plus some shell-only commands that you can use for tuning
performance and diagnosing problems.

The impala-shell command fits into the familiar Unix toolchain:

The -q option lets you issue a single query from the command line, without starting the
interactive interpreter. You could use this option to run impala-shell from inside a shell
script or with the command invocation syntax from a Python, Perl, or other kind of script.

The -f option lets you process a file containing multiple SQL statements,
such as a set of reports or DDL statements to create a group of tables and views.

The --var option lets you pass substitution variables to the statements that
are executed by that impala-shell session, for example the statements
in a script file processed by the -f option. You encode the substitution variable
on the command line using the notation
--var=variable_name=value.
Within a SQL statement, you substitute the value by using the notation ${var:variable_name}.
This feature is available in Impala 2.5 and higher.

The -o option lets you save query output to a file.

The -B option turns off pretty-printing, so that you can produce comma-separated,
tab-separated, or other delimited text files as output. (Use the --output_delimiter option
to choose the delimiter character; the default is the tab character.)

In non-interactive mode, query output is printed to stdout or to the file specified by the
-o option, while incidental output is printed to stderr, so that you can
process just the query output as part of a Unix pipeline.