UNSAFE_CAST()
All functions > CORE > UNSAFE_CAST()
Returns the given expression casted to the given type, allowing to change or remove entity type
Signatures
Returns: The expression converted to the specified type, or NULL if conversion fails
UNSAFE_CAST(expr: T, as_type: DataTypeEnum.TYPE) → U sql
| Parameter | Type | Required | Description |
|---|---|---|---|
expr | T | Yes | The expression to convert |
as_type | DataTypeEnum.TYPE | Yes | The target data type |
Notes
- Same as CAST but allowing to change or remove entity type
See also
Examples
Typical casts
FeatureQL
SELECT
f1 := UNSAFE_CAST('123' AS BIGINT), -- Valid string to integer
f2 := UNSAFE_CAST(3.14E0 AS BIGINT), -- Double truncates toward zero
f3 := UNSAFE_CAST('2024-06-01' AS DATE) -- String to DATE
;Result
| f1 BIGINT | f2 BIGINT | f3 TIMESTAMP |
|---|---|---|
| 123 | 3 | 2024-06-01 |
On this page