Database Reference
In-Depth Information
Data types
A data type is an attribute that specifies the type of data that the object can hold, such
as integer data, character data, monetary data, date and time data, and binary strings.
In Impala, the data in each and every table belongs to some kind of data type; so, it is
very important to understand various data types supported in Impala. Each data type
has its range and the value belonging to the data type stays within the range. Impala
does not convert any data type to another data type by itself, and if a conversion is
needed the CAST operator can be used to transform some of the data types to others.
I have included the use of CAST operator where it is applicable.
Let's start learning some of most common data types in Impala as follows:
BOOLEAN : While creating a table, you can define a field or column in the
tables as a BOOLEAN data type, and the Boolean value represents either
true or false choices. These values can be written in uppercase, lowercase,
or mixed case. However, when these values are queried from a table, these
values are returned in lowercase as true or false .
Here is an example of using the boolean operator:
[Hadoop.testdomain:21000] > create table
list (item string, listed boolean);
Query: create table list (item string,
listed boolean)
It can be noted that the CAST() operator can be used to convert numeric val-
ues to Boolean values. A value 0 represents false and any non-zero value
is converted to true . String values cannot be converted to BOOLEAN values;
however, BOOLEAN values can be converted to strings, returning 1 for true
and 0 for false .
INT : INT in Impala represents a 4-byte integer type of data when used with
CREATE TABLE or ALTER TABLE . The value of INT in Impala ranges
between -2147483648 and 2147483647, and there is no UNSIGNED subtype
with INT.
Search WWH ::




Custom Search