Skip to main content

Conversion functions

Trino will implicitly convert numeric and character values to the correct type if such a conversion is possible. Trino will not convert between character and numeric types. For example, a query that expects a varchar will not automatically convert a bigint value to an equivalent varchar. When necessary, values can be explicitly cast to a particular type.

Conversion functions

cast

Explicitly cast a value as a type. This can be used to cast a varchar to a numeric value type and vice versa.

try_cast

Like cast, but returns null if the cast fails.

Formatting

format

Returns a formatted string using the specified format string and arguments:

format_number

Returns a formatted string using a unit symbol:

Data size

The parse_data_size function supports the following units:

parse_data_size

Parses string of format value unit into a number, where value is the fractional number of unit values:

Miscellaneous

typeof

Returns the name of the type of the provided expression: