CAST
All functions > CONVERSION > CAST
Returns the given expression casted to the given type.
Syntax
CAST(expr, as_type)
sql
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
expr | BIGINT | Yes | The expression to convert |
as_type | TYPE | Yes | The target data type |
Returns
The expression converted to the specified type
Notes
- Converts a value from one data type to another
- Supports conversions between numeric types (BIGINT, DECIMAL, DOUBLE)
- Supports conversions between numeric and string types (VARCHAR)
- Special handling for ROW and ARRAY types
- Conversion may fail if the value cannot be represented in the target type
- NULL values remain NULL after casting
- Precision may be lost when converting between numeric types
- Follows SQL standard casting rules