Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Impala Select statement


May 26, 2021 impala


Table of contents


Impala SELECT statements are used to extract data from one or more tables in the database. This query returns data as a table.

Statement

The following is the syntax of the Impala select statement.

SELECT column1, column2, columnN from table_name;

Here, column1, column2 ... i s the field of the table whose value you want to get. If you want to get all the available fields in a field, you can use the following syntax -

SELECT * FROM table_name;

Cases

Let's say we have a table called customers in Impala that contains the following data -

ID    NAME       AGE    ADDRESS      SALARY
---   -------    ---    ----------   -------
1     Ramesh     32     Ahmedabad    20000
2     Khilan     25     Delhi        15000
3     Hardik     27     Bhopal       40000
4     Chaitali   25     Mumbai       35000
5     kaushik    23     Kota         30000
6     Komal      22     Mp           32000

You can use the select statement to get the id, name, andage of all records of the customers table, as shown below -

[quickstart.cloudera:21000] > select id, name, age from customers;

When performing the query above, Impala gets the id, name, age of all records from the specified table and displays them, as shown below.

Query: select id,name,age from customers

+----+----------+-----+
| id | name     | age |
| 1  | Ramesh   | 32  |
| 2  | Khilan   | 25  |
| 3  | Hardik   | 27  |
| 4  | Chaitali | 25  |
| 5  | kaushik  | 23  |
| 6  | Komal    | 22  |
+----+----------+-----+

Fetched 6 row(s) in 0.66s

You can also use the select query to get all records from the customers table, as shown below.

[quickstart.cloudera:21000] > select name, age from customers; 
Query: select * from customers

When performing the above query, Impala extracts and displays all records from the specified table, as shown below.

+----+----------+-----+-----------+--------+
| id | name     | age | address   | salary |
+----+----------+-----+-----------+--------+
| 1  | Ramesh   | 32  | Ahmedabad | 20000  |
| 2  | Khilan   | 25  | Delhi     | 15000  |
| 3  | Hardik   | 27  | Bhopal    | 40000  |
| 4  | Chaitali | 25  | Mumbai    | 35000  |
| 5  | kaushik  | 23  | Kota      | 30000  |
| 6  | Komal    | 22  | MP        | 32000  |
+----+----------+-----+-----------+--------+

Fetched 6 row(s) in 0.66s

Use Hue to get records

Open the Impala query editor and type the select statement in it. Then click the execute button, as shown in the screenshot below.

Impala Select statement

After you execute the query, if you scroll down and select the Results tab, you can see a list of records for the specified table, as shown below.