CAST
Convert a value to another data type; invalid conversions raise an error.
Try an expression
In Formula, enter the expression and set Output type to VARCHAR.
Example input
- Row 1
amount = 20 - Row 2
amount = 120 - Row 3
amount = NULL
Expression
CAST(amount AS VARCHAR)Result
Row 1: '20'
Row 2: '120'
Row 3: NULLNULL means the value is missing.
Arguments and types
CAST(expr AS type)The result type can depend on the input types. See DuckDB for the full argument rules.
Things to know
Formula output conversion
For this example, set Output type to DOUBLE.
'not a number'Every row: NULL
An invalid conversion raises an error
CAST('unknown' AS DOUBLE)This input is rejected: Could not convert string 'unknown' to DOUBLE
Function metadata from DuckDB, used under the MIT license.