View a markdown version of this page

Utility functions in DuckDB - Amazon Athena

Utility functions in DuckDB

The following table lists the utility functions, with a link to the description of each one.

Function Description

alias

Returns the name that the engine gives an expression, as a string.

assert_true

Makes the query fail when a condition is not true, and otherwise returns NULL.

can_cast_implicitly

Returns whether the engine can convert a value of one data type to another data type without an explicit cast.

cast_to_type

Converts a value to the data type of another value.

constant_or_null

Returns NULL if any argument after the first is NULL, and otherwise returns the first argument.

create_sort_key

Builds a single value that sorts in the same order as one or more values with the sort orders that you choose.

current_catalog

Returns the name of the engine's own database, which is not the name of the catalog that your query uses.

current_database

Returns the name of the engine's own database, which is not the name of an AWS Glue database.

current_role

Returns the fixed string duckdb, not the IAM identity that runs the query.

current_schema

Returns the name of the engine's own default schema, which is not the database that your query uses.

current_schemas

Returns the list of schemas on the engine's search path.

current_user

Returns the engine's fixed user name, duckdb.

enum_code

Returns the position of an ENUM value in its ENUM type, starting at 0.

enum_first

Returns the value that comes first in the list of values of an ENUM type.

enum_last

Returns the value that comes last in the list of values of an ENUM type.

enum_range

Returns a list of the values that an ENUM type defines, in the order of the type.

enum_range_boundary

Returns the values of an ENUM type from one value through another, as a list.

equi_width_bins

Splits a range of values into bins of equal width and returns the list of their upper bounds, which you can pass to histogram.

error

Fails the query with an error message that you choose.

gen_random_uuid

Alias of uuid.

get_type

Returns a TYPE value that describes the data type of an expression.

glob

Lists the files in Amazon S3 whose paths match a glob pattern.

hash

Returns a 64-bit hash of one or more values.

if

Returns one of two values, depending on whether a condition is true.

in_search_path

Tests whether a schema of a database is in the search path of the current session.

make_type

Builds a data type from a type name and the type's parameters.

nullif

Returns NULL if two values are equal, and otherwise returns the first value.

replace_type

Casts every part of a value that has one data type to another data type, including parts inside nested values.

session_user

Alias of current_user.

stats

Returns the statistics that the engine has about an expression when it plans the query.

typeof

Identifies the data type of an expression and returns its name, such as INTEGER.

user

Alias of current_user.

uuid

Returns a random version 4 UUID.

uuid_extract_timestamp

Returns the creation time that is stored in a version 7 UUID.

uuid_extract_version

Returns the version number of a UUID.

uuidv4

Alias of uuid.

uuidv7

Returns a version 7 UUID, which starts with its creation time.

variant_array_length

Returns the number of elements in a VARIANT array.

variant_contains

Tests whether a VARIANT value contains another VARIANT value at any level.

variant_exists

Tests whether a VARIANT object has a key.

variant_extract

Returns the value of an object key or an array element from a VARIANT value.

variant_extract_string

Returns the value of an object key in a VARIANT value as text.

variant_group_array

Collects the values of a group into a VARIANT array.

variant_group_object

Collects the key-value pairs of a group into a VARIANT object.

variant_keys

Returns the keys of a VARIANT object.

variant_type

Returns the type name of a VARIANT value or of a value in a VARIANT object.

variant_typeof

Returns the detailed type of a VARIANT value.

version

Returns the release line of open-source DuckDB that the engine is built from.