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:
-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.
-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.
--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.
-o
option lets you save query output to a file.
-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.)
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.
impala-shell
uses the readline
facility to recall
and edit previous commands.
For information on installing the Impala shell, see Installing Impala.
For information about establishing a connection to a coordinator Impala
daemon through the impala-shell
command, see Connecting to Impala Daemon from impala-shell.
For a list of the impala-shell
command-line options, see
impala-shell Configuration Options. For reference information about the
impala-shell
interactive commands, see
impala-shell Command Reference.