Conversion
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:
Unit | Description | Value |
---|---|---|
B | Bytes | 1 |
kB | Kilobytes | 1024 |
MB | Megabytes | 10242 |
GB | Gigabytes | 10243 |
TB | Terabytes | 10244 |
PB | Petabytes | 10245 |
EB | Exabytes | 10246 |
ZB | Zettabytes | 10247 |
YB | Yottabytes | 10248 |
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: