Impala supports the following utility functions that do not operate on a particular column or data type:
default
if no database has been selected, or whatever database the
session switched to through a USE
statement or the
impalad -d
option.
Return type: STRING
USER()
. If
delegation is enabled, it returns the ID of the delegated user.
Return type: STRING
Added in: Impala 2.2.5
The function returns NULL
if the input json_str
is invalid or if nothing is selected based on the selector JSON
path.
Return type: STRING
Examples:
---- QUERY
SELECT GET_JSON_OBJECT ('{"a":true, "b":false, "c":true}', '$.*');
---- RESULTS
[true,false,true]
---- QUERY
SELECT GET_JSON_OBJECT(t.json, '$.a.b.c') FROM (VALUES (
('{"a": {"b": {"c": 1}}}' AS json),
('{"a": {"b": {"c": 2}}}'),
('{"a": {"b": {"c": 3}}}')
)) t
---- RESULTS
'1'
'2'
'3'
---- QUERY
SELECT GET_JSON_OBJECT(t.json, '$.a'),
GET_JSON_OBJECT(t.json, '$.b'),
GET_JSON_OBJECT(t.json, '$.c')
FROM (VALUES (
('{"a":1, "b":2, "c":3}' AS json),
('{"b":2, "c":3}'),
('{"c":3}')
)) t
---- RESULTS
'1','2','3'
'NULL','2','3'
'NULL','NULL','3'
---- QUERY
SELECT GET_JSON_OBJECT(t.json, '$[1]'),
GET_JSON_OBJECT(t.json, '$[*]')
FROM (VALUES (
('["a", "b", "c"]' AS json),
('["a", "b"]'),
('["a"]')
)) t
---- RESULTS
'b','["a","b","c"]'
'b','["a","b"]'
'NULL','a'
Added in: Impala 3.1
USER()
. If
delegation is enabled, it returns the ID of the delegated user.
LOGGED_IN_USER()
is an alias of EFFECTIVE_USER()
.
Return type: STRING
Added in: Impala 3.1
Return type: INT
SELECT
list, it is
called once for each row in the result set; adjust the number of milliseconds
accordingly. For example, a query SELECT *, SLEEP(5) FROM
table_with_1000_rows
would take at least 5 seconds to complete (5
milliseconds * 1000 rows in result set). To avoid an excessive number of concurrent
queries, use this function for troubleshooting on test and development systems, not
for production queries.
Return type: N/A
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 as user@example.com
, in a Kerberized environment.
When delegation is enabled, consider calling the EFFECTIVE_USER()
function instead.
Return type: STRING
Each call to UUID()
produces a new arbitrary value.
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.
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. The
UUID()
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.
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)
impalad
daemon that is acting as the coordinator
for
the current query.
Return type: STRING
Added in: Impala 3.1