
data, the user creates tables via the familiar
CREATE TABLE
statement, which, in addition to providing the logical schema
of the data, also indicates the physical layout, such as file
format(s) and placement within the HDFS directory struc-
ture. Those tables can then be queried with standard SQL
syntax.
2.1 Physical schema design
When creating a table, the user can also specify a list of
partition columns:
CREATE TABLE T (...) PARTITIONED BY (day int, month
int) LOCATION ’<hdfs-path>’ STORED AS PARQUET;
For an unpartitioned table, data files are stored by de-
fault directly in the root directory
3
. For a partitioned
table, data files are placed in subdirectories whose paths
reflect the partition columns’ values. For example, for day
17, month 2 of table T, all data files would be located in
directory
<root>/day=17/month=2/
. Note that this form of
partitioning does not imply a collocation of the data of an
individual partition: the blocks of the data files of a partition
are distributed randomly across HDFS data nodes.
Impala also gives the user a great deal of flexibility when
choosing file formats. It currently supports compressed and
uncompressed text files, sequence file (a splittable form of
text files), RCFile (a legacy columnar format), Avro (a binary
row format), and Parquet, the highest-performance storage
option (
Section 5.3
discusses file formats in more detail).
As in the example above, the user indicates the storage
format in the
CREATE TABLE
or
ALTER TABLE
statements. It
is also possible to select a separate format for each partition
individually. For example one can specifically set the file
format of a particular partition to Parquet with:
ALTER TABLE PARTITION(day=17, month=2) SET FILEFORMAT
PARQUET.
As an example for when this is useful, consider a table
with chronologically recorded data, such as click logs. The
data for the current day might come in as CSV files and get
converted in bulk to Parquet at the end of each day.
2.2 SQL Support
Impala supports most of the SQL-92
SELECT
statement
syntax, plus additional SQL-2003 analytic functions, and
most of the standard scalar data types: integer and floating
point types, STRING, CHAR, VARCHAR, TIMESTAMP,
and DECIMAL with up to 38 digits of precision. Custom
application logic can be incorporated through user-defined
functions (UDFs) in Java and C++, and user-defined aggre-
gate functions (UDAs), currently only in C++.
Due to the limitations of HDFS as a storage manager, Im-
pala does not support
UPDATE
or
DELETE
, and essentially only
supports bulk insertions (
INSERT INTO ... SELECT ...
)
4
.
Unlike in a traditional RDBMS, the user can add data to a
table simply by copying/moving data files into the directory
3
However, all data files that are located in any directory
below the root are part of the table’s data set. That is a
common approach for dealing with unpartitioned tables,
employed also by Apache Hive.
4
We should also note that Impala supports the
VALUES
clause. However, for HDFS-backed tables this will generate
one file per
INSERT
statement, which leads to very poor
performance for most applications. For HBase-backed
tables, the
VALUES
variant performs single-row inserts by
means of the HBase API.
location of that table, using HDFS’s API. Alternatively, the
same can be accomplished with the LOAD DATA statement.
Similarly to bulk insert, Impala supports bulk data dele-
tion by dropping a table partition (
ALTER TABLE DROP PAR-
TITION
). Because it is not possible to update HDFS files
in-place, Impala does not support an
UPDATE
statement. In-
stead, the user typically recomputes parts of the data set to
incorporate updates, and then replaces the corresponding
data files, often by dropping and re-adding the partition
After the initial data load, or whenever a significant frac-
tion of the table’s data changes, the user should run the
COMPUTE STATS <table>
statement, which instructs Impala
to gather statistics on the table. Those statistics will subse-
quently be used during query optimization.
3. ARCHITECTURE
Impala is a massively-parallel query execution engine,
which runs on hundreds of machines in existing Hadoop
clusters. It is decoupled from the underlying storage engine,
unlike traditional relational database management systems
where the query processing and the underlying storage engine
are components of a single tightly-coupled system. Impala’s
high-level architecture is shown in Figure 1.
An Impala deployment is comprised of three services. The
Impala daemon (impalad) service is dually responsible for
accepting queries from client processes and orchestrating their
execution across the cluster, and for executing individual
query fragments on behalf of other Impala daemons. When
an Impala daemon operates in the first role by managing
query execution, it is said to be the coordinator for that query.
However, all Impala daemons are symmetric; they may all
operate in all roles. This property helps with fault-tolerance,
and with load-balancing.
One Impala daemon is deployed on every machine in the
cluster that is also running a datanode process - the block
server for the underlying HDFS deployment - and therefore
there is typically one Impala daemon on every machine. This
allows Impala to take advantage of data locality, and to read
blocks from the filesystem without having to use the network.
The Statestore daemon (statestored) is Impala’s meta-
data publish-subscribe service, which disseminates cluster-
wide metadata to all Impala processes. There is a single
statestored instance, which is described in more detail in
Section 3.1 below.
Finally, the Catalog daemon (catalogd), described in
Section 3.2
,
serves as Impala’s catalog repository and metadata access
gateway. Through the catalogd, Impala daemons may exe-
cute DDL commands that are reflected in external catalog
stores such as the Hive Metastore. Changes to the system
catalog are broadcast via the statestore.
All these Impala services, as well as several configuration
options, such as the sizes of the resource pools, the available
memory, etc.. (see
Section 6
for more details about resource
and workload management) are also exposed to Cloudera
Manager, a sophisticated cluster management application
5
.
Cloudera Manager can administer not only Impala but also
pretty much every service for a holistic view of a Hadoop
deployment.
5
http://www.cloudera.com/content/cloudera/en/products-
and-services/cloudera-enterprise/cloudera-manager.html
评论