Impala Miscellaneous Functions
Impala supports the following utility functions that do not operate on a particular column or data type:
-
current_database()
-
Purpose: Returns the database that the session is currently using, either
default
if no database has been selected, or whatever database the session switched to through aUSE
statement or the impalad-d
option.Return type:
string
-
effective_user()
-
Purpose: Typically returns the same value as
user()
, except if delegation is enabled, in which case it returns the ID of the delegated user.Return type:
string
Added in: Impala 2.2.5
-
pid()
-
Purpose: Returns the process ID of the impalad daemon that the session is
connected to. You can use it during low-level debugging, to issue Linux commands that trace, show the
arguments, and so on the impalad process.
Return type:
int
-
user()
-
Purpose: Returns the username of the Linux user who is connected to the impalad
daemon. Typically called a single time, in a query without any
FROM
clause, to understand how authorization settings apply in a security context; once you know the logged-in username, you can check which groups that user belongs to, and from the list of groups you can check which roles are available to those groups through the authorization policy file.In Impala 2.0 and later,
user()
returns the full Kerberos principal string, such asuser@example.com
, in a Kerberized environment.When delegation is enabled, consider calling the
effective_user()
function instead.Return type:
string
-
uuid()
-
Purpose: Returns a universal unique identifier, a 128-bit value encoded as a string with groups of hexadecimal digits separated by dashes.
Return type:
string
Added in: Impala 2.5.0
Usage notes:
Ascending numeric sequences of type
BIGINT
are often used as identifiers within a table, and as join keys across multiple tables. Theuuid()
value is a convenient alternative that does not require storing or querying the highest sequence number. For example, you can use it to quickly construct new unique identifiers during a data import job, or to combine data from different tables without the likelihood of ID collisions.Examples:
-- Each call to uuid() produces a new arbitrary value. select uuid(); +--------------------------------------+ | uuid() | +--------------------------------------+ | c7013e25-1455-457f-bf74-a2046e58caea | +--------------------------------------+ -- If you get a UUID for each row of a result set, you can use it as a -- unique identifier within a table, or even a unique ID across tables. select uuid() from four_row_table; +--------------------------------------+ | uuid() | +--------------------------------------+ | 51d3c540-85e5-4cb9-9110-604e53999e2e | | 0bb40071-92f6-4a59-a6a4-60d46e9703e2 | | 5e9d7c36-9842-4a96-862d-c13cd0457c02 | | cae29095-0cc0-4053-a5ea-7fcd3c780861 | +--------------------------------------+
-
version()
-
Purpose: Returns information such as the precise version number and build date for the
impalad
daemon that you are currently connected to. Typically used to confirm that you are connected to the expected level of Impala to use a particular feature, or to connect to several nodes and confirm they are all running the same level of impalad.Return type:
string
(with one or more embedded newlines)